Questions tagged [regex]
Regular expressions provide a declarative language to match patterns within strings. They are commonly used for string validation, parsing, and transformation. Specify the language (PHP, Python, etc) or tool (grep, VS Code, Google Analytics, etc) that you are using. Do not post questions asking for an explanation of what a symbol means or what a particular regular expression will match.
260,417
questions
1
vote
0
answers
8
views
VBA Backreferencing using Regular Expressions Find and Replace
I want to standardize the formatting of some text within a Word document using VBA and regEx. For example, my document would contain text strings such as "Qty #", "Qty (#)", "...
0
votes
0
answers
17
views
RegEx - String contains specific verbiage [duplicate]
I am new to RegEx, but I am trying to setup a process that sets a designated 'Role' based on an employee's title.
For instance, I have a list of key phrases that point to the user having a role of '...
-1
votes
1
answer
28
views
Return the sum of all the numbers contained within the string
Instructions
The sumNums function takes a string as an argument. It should return the sum of all the numbers contained within the string. If there are no numbers in the string, sumNums should return 0....
0
votes
0
answers
12
views
Regex - lookahead and between [duplicate]
Suppose I have this structure of strings. I have >100k.
'xxxxxx0AxxZZxxBBxxxxx1AxxxxxBB' --Group1 is 1
'xxxxxxxxx0AxxxxZZxxxxx1AxxxxxBBxxxx' --Group1 is 1
'...
-2
votes
0
answers
28
views
How to get all occurrences of a string using regex in R? [duplicate]
Let's say I have a string
Str1 -> "[18.01,19.023],[20.0289,20.9273],[32.474742,284.383732]"
This is like a set of coordinates of type [x,y] and I want to extract all the "x" and ...
-1
votes
2
answers
73
views
Regex for matching numbers >= 150,000 with spaces included not working as expected
I'm trying to create a regex that matches numbers greater than or equal to 150 000, considering spaces as thousand separators. Here is the regex I tried:
^(150\s*000|1[5-9]\d{2}(\s*\d{3})*|[2-9]\d{2}(\...
5
votes
4
answers
68
views
Capturing all matches of a string value from an array of regex patterns, while prioritizing closest matches
Let's say I have an array of names, along with a regex union of them:
match_array = [/Dan/i, /Danny/i, /Daniel/i]
match_values = Regexp.union(match_array)
I'm using a regex union because the actual ...
0
votes
0
answers
55
views
regex expression doesn't match, if i put ? after a group
I want to get some information from html text using Python. This regex expression captures multiple times throughout the text.
def regexanje(tekst):
re_ime = r'<span class="font_xlarge&...
-10
votes
0
answers
103
views
regex get everything between first and last double quotes each line [closed]
I want get with regex pattern everything between first and last double quotes in each line
text:
Example Title --- "Values"
Example Title --- "Valu"es"
I want get like this:
...
-1
votes
0
answers
33
views
What will be the Regex to validate date format YYYY-MM-DD? [duplicate]
I am looking to get the regex for the date format mentioned above.
I tried /^[0-9]{1,2}/[0-9]{1,2}/[0-9]{4}$/ but got the format of DD/MM/YYYY.
This did not work either /([12]\d{3}-(0[1-9]|1[0-2])-(0[...
0
votes
1
answer
32
views
How to redirect an url with a specific folder to another, whatever the page?
I tried for hours to redirect in an htaccess every pages of a folder to new url, matching the folder but it seems I definitely do not understand nothing to regex and redirect !
I want to redirect any ...
-4
votes
0
answers
19
views
Add global flag to regex js [duplicate]
My regex \W?\s?no_info\W? should have /g flag added to it, but I can't get the symbols right.
/g should be at the end of regex expression, \W?\s?no_info\W?\/g doesn't count /g as global, but as ...
-1
votes
0
answers
35
views
How to find a pattern within nested delimiter pairs using grep or similar?
I'd like to match a pattern occurring within an arbitrary nesting of delimiter pairs (in my case, braces/curly brackets). For example, if the pattern was "abc", I'd like to match any of the ...
-3
votes
1
answer
79
views
Can I replace one char group by another using RegEx? [closed]
I want to replace "á" by "a", "é" by "e", etc...
Can I do this with single RegEx?
Find: /[áéíóúý]/
Replace: ???
Maybe replacement can contain separated list ...
0
votes
0
answers
19
views
Elasticsearch query with regex for digits is not working as expected [duplicate]
I have an index in elastic with field messages like this:
Start publishing 11 trade jobs...
Start publishing 123 trade jobs...
Start publishing trade jobs...
I want write a query to get all the ...