Skip to main content

Questions tagged [regex]

Regular expressions are a declarative language, mainly used for pattern matching within strings. Please include a tag specifying the programming language you are using, together with this tag.

3 votes
1 answer
146 views

Bulk Text Replacer

I have created a simple text editor with a "replace all" feature. It's meant to be part of a larger project, so it needs to be robust and work reliably across various scenarios. Please ...
Mori's user avatar
  • 147
5 votes
1 answer
103 views

File system regex searcher

This is my first Rust project (I'm primarily a C guy). I want to know if my code is properly idiomatic (Rusty?). Also, are there any inefficiencies? The code defines an iterator (...
Daniel Walker's user avatar
0 votes
0 answers
65 views

Pure loop in RegEx to find the substrings with condition

I want to share my invention, which allows you to use only one RegEx, which will search for substrings in a string with a certain condition. If you want, call it a RegEx loop that didn't exist before! ...
Raf's user avatar
  • 9
3 votes
1 answer
79 views

Polynomial parsing using regular expressions in Python

I've made a code in Python 3 which converts a polynomial with integer coefficients (in simplified integer form) from string form to a list of tuples of the form (coefficient, exponent, variable). It ...
Sam's user avatar
  • 145
2 votes
2 answers
141 views

Faster regex to match all worded numbers from 1 to 99

I would like to know if there is a better regex to match all worded numbers from 1 to 99. With "better" I mean shorter with same performance, OR faster. I came up with this. I can't do ...
Bobby234's user avatar
2 votes
1 answer
55 views

Match pattern in Polars (Python) native API vs the slow map_elements

I have a Polars dataframe in which the cells contain a sequence of single digits as a string of characters, and I want to find the number of differences between the single-digits elements of the ...
Josh9999's user avatar
5 votes
1 answer
356 views

Python function to expand regex with ranges

I attempted to implement a python version of this function in my previous question. Given a regular expression with range(s) of alphabets/numbers, the function will expand the brackets and return a ...
nightstand's user avatar
2 votes
0 answers
91 views

R function to expand range of numbers/alphabets in a regex

I tried writing a short function that expands brackets [] within a regular expression. Given a regular expression, the function will expand the brackets and return ...
nightstand's user avatar
0 votes
0 answers
145 views

Fuzz-test the performance of SmokeDetector's keywords regex

I had an idea for attempting to detect bad performing regexes in Charcoal-SE/SmokeDetector, by using Atheris (a fuzzer for python code). The theory behind it is that a bad performing regex will most ...
micsthepick's user avatar
3 votes
1 answer
98 views

Build a dictionary from a string by the extraction of data from all the pairs <TAG|VAL> contained inside the string and clean string from TAGs

I have written code to manage a string and retrieve from it a dictionary which must contain pairs key-value dependent from the string. To be more clear I'll show ...
User051209's user avatar
2 votes
1 answer
62 views

Combining multiple regexps using the `|` operator and grouping the regexps by their flags

I've implemented a function that creates a multiple regular expressions predicate. The idea behind the predicate is combining regular expressions using the disjunction operator ...
terrorrussia-keeps-killing's user avatar
1 vote
1 answer
148 views

Function, which replaces consecutive white-space with a single white-space

Task-description: Implement a function, which returns a string with all consecutive whites-spaces replaced as a single-space. Example: "a[space][space][space]b[space][space][space]c" shall ...
michael.zech's user avatar
  • 4,814
2 votes
1 answer
62 views

Multiple regexp replace in string

I made a function that prompts me for values of variables (formatted %^{var1}) it found in a string and fills in said values. ...
my_display_name's user avatar
9 votes
2 answers
980 views

Swift-function which counts the letters, numbers, spaces, special chars in a given string

Task description: Write a function, which counts the letters, spaces, number and special characters in string. My implementation: ...
michael.zech's user avatar
  • 4,814
6 votes
1 answer
1k views

Username Validation RegExp

Working through the freeCodeCamp JavaScript curriculum and I found this RegExp task surprisingly tricky (maybe I just don't use RegExp very much). The parameters are: Usernames can only use alpha-...
Christopher Fimbel's user avatar

15 30 50 per page
1
2 3 4 5
58