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,540
questions
1
vote
2
answers
54
views
Replace Spaces with New Lines in Comma-Separated Number Lines
I have a list like following:
\u042f 12,197,051
\ube44\ud574 93,721,409
HUMAN 45,754,677
Overwatch 43,437,031 OVERWATE
Now I want to replace spaces with new lines in Comma-Separated number lines like ...
0
votes
3
answers
159
views
Issue while masking Credit Card No. before and/or after spaces
I am having an issue when there is a space before/after in CreditCardNo.
For example from INV 2420852290 to SAV 0165487. Here 2420852290 is 10-digits and still it is getting masked.
For a CreditCardNo,...
2
votes
1
answer
79
views
Using callable_iterator (re.finditer) causes Python to freeze
I have a function that is called for every line of a text.
def tokenize_line(line: str, cmd = ''):
matches = re.finditer(Patterns.SUPPORTED_TOKENS, line)
tokens_found, not_found, start_idx = []...
0
votes
0
answers
33
views
Regex: Find all matches between varying length sets of identical special characters [duplicate]
I have texts similar to this:
<FILE_NAME>
���������������
</FILE_NAME>
<SHEET_NAMES>
['��������']
</SHEET_NAMES>
<RAW_STRINGS>
[������������]
Where any length of the ...
3
votes
1
answer
69
views
Making sense of the regex in grep command [closed]
When executing the following command in a bash shell:
grep '^\(.\)*\1$' exp.txt
I expect it to match any line that:
begins and ends with the same latter.
but in reality it matches the following ...
-1
votes
1
answer
49
views
Match string but not if it's preceded by a different word [duplicate]
I want a regex to match "email" but not "verify email".
How can I do this?
I've tried the following but no luck:
[^(verify)] email
3
votes
1
answer
69
views
Extracting specific substrings from a text field in SQL
Consider this snippet code to regenerate the result set:
CREATE SCHEMA "clean";
CREATE TABLE "clean"."InvoiceFact" (
"InvoiceTitle" TEXT
);
INSERT INTO &...
-1
votes
0
answers
16
views
Check if string contains any item of array in mongoose find query [duplicate]
I'm trying to find entries where the title field contains any item of an array.
Here is the relevant part of my schema:
const blogSchema = mongoose.Schema({
title: {
type: String,
required: ...
0
votes
1
answer
50
views
How to Remove Duplicate Elements in an XML File Using Regex in VS Code?
I have an XML file with several elements, and each child of item appears twice. The file looks something like this:
<item>
<array name="time_entries">
<item>0&...
-2
votes
1
answer
70
views
Regex match exact item in Google sheets
I'm trying to use the regexmatch function in Google Sheets to match the item "hip hop" in the bolded cases in the lists below:
- atl hip hop, dirty south rap, hip hop, pop rap
- hip hop, ...
-1
votes
0
answers
30
views
What is the difference in using '?' inside and outside a group? [duplicate]
I am trying to match strings such as the following.
Valid
12345678
12-34-56-87
Invalid
1-234-56-78
12-45-7810
#include<regex>
using namespace std;
int main() {
string s = "";...
0
votes
1
answer
45
views
python regex, how to unpack multiple group when group may not exit [closed]
# Code
re_freq = re.compile(r'^(?P<num>\d+)?(?P<freq>\w)')
for input in ['4S', '3W', 'S', 'W']:
print(f'input: {input}:')
num, freq = re_freq.search(input).group()
print(f'. ...
1
vote
2
answers
108
views
Replace variables in a formula with their definitions [closed]
I have the list of variables and their corresponding definitions. I also have the formulas, provided, but I would like the translation of the formulas (provided in the example) to better understand ...
-1
votes
0
answers
13
views
How to extract the class name only by using default toString method and regular expression together? [duplicate]
I used the following :
let s = { x: 1, y: 1 }.toString(); // s == "[object Object]"
console.log(/\b(\w)+]$/.exec(s)[0]);
It gives the output : Object]
How to get rid of closing squre ...
1
vote
1
answer
52
views
Regex: split string into sets of chars from a pool
Is there a way to describe a regex splitting a string into sets of chars from a limited pool without duplications? For example we have pool of chars (A, B, and C), so string "AABABCCAB" gets ...