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.
48
questions
-2
votes
2
answers
15
views
Oracle regexp_replace entire matching word
Input:
ABC DEF GHIJ123A KLM GHIJ456B RST UVW GHIJ789C
Ouput:
ABC DEF GHIJ000X KLM GHIJ000X RST UVW GHIJ000X
So, I want to find all instances of words in the string that start with GHIJ and replace ...
-2
votes
1
answer
18
views
Regex matching online but not in App Script for MMM-YYYY [duplicate]
This is my Regex Pattern to match Date format MMM-YYYY(Apr-23). I have checked this on Regex101 it works as expected.
(\b\d{1,2}\D{0,3})?\b(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|Jun(?:...
-1
votes
0
answers
22
views
Is there php redirect function that will be redirect if match referer only? [closed]
I try like following but it doesn’t work in sometimes.
<?php
$refer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;
if( preg_match("/anysite1/i", $refer) or ...
-2
votes
0
answers
19
views
add double quote delimiters to a tab separated file in notepad++ [closed]
I have a tab separated file where I need to add double quote delimiters around the text fields. Not all the text fields start with a letter, some start with numbers. There are also number and date ...
1
vote
1
answer
24
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
19
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
2
answers
47
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 ...
1
vote
0
answers
18
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
29
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
77
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
5
answers
96
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&...
-9
votes
0
answers
125
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
vote
1
answer
33
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 ...