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.
868 questions
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 ...
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 (...
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! ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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.
...
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:
...
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-...