261,123 questions
Best practices
2
votes
2
replies
95
views
Text search versus regular expressions
I'm doing text search with user entered queries against multiple sources documents.
The user can enter 16 MB or 16MB and the document can contain one or the other. I could not make it with pure text ...
Advice
2
votes
11
replies
190
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
82
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 ...
Best practices
0
votes
18
replies
372
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
230
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
89
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
207
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 ...
6
votes
2
answers
110
views
Why do negative lookbehind and optional group allow a match?
I have a regex where a negative lookbehind and an optional group is producing a match when I'm not expecting it to. There appears to be something about their interaction that I am not understanding, ...
Advice
1
vote
6
replies
77
views
How to match any amount of Unicode characters (letters, numbers, surrogate pairs) in regex?
How to match any amount of Unicode characters (letters, numbers, surrogate pairs) in regex:
😆
ẘ😆
😆😆
ẘaሴ
abc123
I am looking for an equivalent to /^(\[a-zA-Z0-9\]+$)/i that finds ASCII.
Best practices
2
votes
4
replies
61
views
How to parse informal Persian number words into an integer currency value (Rial)
I need to convert informal Persian user input that represents a monetary amount into a single integer value in rials in python.
The input is free-form and may include:
Persian number words (e.g. یک, ...
1
vote
0
answers
107
views
Mongo driver C# is always using global flag for regex
I have a generic function to always query my mongo collection with a limit and get the entire result in a single batch.
I noticed the queries with Contains and StartWith were taking longer than ...
0
votes
1
answer
118
views
How to parse tab delimited header based on multiple header lines with spaces in R
I am working with older weather data files with a 3-line header. The first line identifies the station, the second provides column names, and the third gives the column units. The problem is that ...
0
votes
2
answers
138
views
How to exclude subtotal lines from result
Invoice contains services and Subtotal rows:
Internet_Usage 1058 187822_MB 1 000 000
PhoneCalls 48 02:42:39 2 000 000
Subtotal 3 302 5998
Parking 8 4 000 000
Subtotal 4 302 5998
sum is third number ...
1
vote
4
answers
106
views
SAS prxmatch how to deal with searching for a " within the middle of the expression?
%if %sysfunc(prxmatch(/^\("([A-Za-z])"\)$/, %str(&names))) = 0 and %upcase(&stringC) = N %then %do;
%put ERROR: Please format as such ("obesity","diabetes&...