11 questions from the last 30 days
1
vote
1
answer
32
views
How to use a regular expression in R as the replacement in gsub
I have file names with text in them that looks like "1999_2000" (year followed by underscore then year). The years change. I want to change the underscore to a hyphen ("-"). I'...
-9
votes
0
answers
141
views
Remove special characters from a string except emojis [closed]
I want to remove all special characters from a string except emojis.
var stringWithEmoji = "test 😎";
var cleanedString = stringWithEmoji.replace(/[^a-zA-Z0-9\s]/g, '');
The above replace ...
0
votes
1
answer
114
views
Regexp capturing only letters but excluding a specific letter [duplicate]
Is there a better way to define a regexp that captures only letters but not a given letter, for example not "S" or "s"?
[^Ss] -> this one does not limit the characters to ...
Advice
2
votes
11
replies
167
views
Integer Partition Regex
I need to construct a regex given an integer n that matches any partition of n with a leading +. For example, if n=10, it should match +10, +9+1, +1+9, +1+8+1 etc.
Since there are only finitely many ...
0
votes
2
answers
69
views
Replace regex with Jinja2
I use Jinja2 and mixhtml for validating length of the input from the user.
From my app.py two cons
USER_USERNAME_MIN = 2
USER_USERNAME_MAX = 20
But I'm not sure how to place them into the input ...
-3
votes
4
answers
174
views
Python Regex for a closing parenthesis without an opening parenthesis [closed]
I am looking to write a regex pattern that recognizes when my text has a single open parenthesis. I wrote this code below to search for a single left hand parenthesis with no right hand parenthesis. I ...
Best practices
0
votes
18
replies
350
views
How programmers really finds out which 'regex' is required for their solution?
I often struggle to decide which regex pattern fits a requirement. How do experienced programmers approach designing regex? Do they memorize common patterns, build them step by step, or rely on ...
0
votes
3
answers
135
views
RegEx Find all words that are NOT in line with a starting Single Quote
This will be used in a Classic ASP (VBScript) project.
I am trying to find the words that are NOT in line with a starting single quote.
Regex example of finding all words.
(\b(CreateObject|Set|Open)\b)...
4
votes
4
answers
228
views
Modify numeric values with Perl one-liner
I would like to use a Perl one-liner to modify numeric values in a text file. My data are stored in a text file:
0, 0, (1.263566e+02, -5.062154e+02)
0, 1, (1.069488e+02, -1.636887e+02)
0, 2, (-2....
2
votes
1
answer
76
views
Dataweave how to use variables in regular expression
I want to use a regular expression in Mulesoft Dataweave and substitute some values by using variables.
I have this code which excecutes fine in Dataweave:
"1000000087" replace /^(.{3}).(.{6}...
1
vote
2
answers
206
views
How to dynamically repeat the replacement string per match with PHP's preg_replace() [duplicate]
We have a capture group of Z, and we want to display this capture group X number of times using regex in PHP.
I can not find a working syntax for this. For example:
This captures the "Z" 5 ...