Skip to main content

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.

0 votes
0 answers
19 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 = "";...
Aadhar Jain's user avatar
0 votes
0 answers
11 views

dbt doc block automation with regex in VSCode

I am trying to automate creating dbt doc blocks in markdown file. My issue is when I have more than one model with their own fields, I'm not sure how to automate doc block creation. So far I have this:...
shellybeans's user avatar
-2 votes
0 answers
50 views

Extract substrings from strings that are separated by variable number of spaces [closed]

I'm looking for a regex to extract a part of the string in C# or vb.net. My string might look like these "Hello, there is cat on the wall. The lion is in its den." "The lion is in its ...
Clement-Edwin ALBERT's user avatar
-1 votes
1 answer
31 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'. ...
Karun's user avatar
  • 619
0 votes
2 answers
79 views

How to replace variables in a formula with their definitions?

I have the list of variables used, 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 ...
Stephen's user avatar
  • 495
-1 votes
0 answers
10 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 ...
Goutam Debnath's user avatar
1 vote
1 answer
42 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 ...
Dmitry Kurkin's user avatar
-1 votes
0 answers
27 views

PHP Notice: Array to string conversion preg_grep Problem

My Code is this $SQLInjectionRegexOR = '/[\'")]* *[o][r] *.*(.)(.) *= *\\2(?:--)?\\1?/i'; Failure - 1 $suspiciousQueryItemsOR = preg_grep($SQLInjectionRegexOR, $_REQUEST); if (!empty($...
dlittel's user avatar
-4 votes
1 answer
55 views

Java String split by empty lines including empty lines at the end [closed]

I have seen many questions and answers online, but it seems that I cannot find the case that I have. String s = "a\nb\n\nc\n\n\n\n"; String[] split = s.split("\\R"); //is the same ...
Matjaz's user avatar
  • 484
2 votes
1 answer
48 views

Sonarlint refactor this repetition that can lead to stack overflow regex expression [duplicate]

I have to write a java regular expression to find if a string has at least 6 digits in it. The digits may be separated by space, hyphen or other characters. The java pattern that I wrote "^(?=.(?:...
gcpd0711's user avatar
1 vote
2 answers
36 views

Extract sub-string within larger block

Given the following partial file: [epel] name=Extra Packages for Enterprise Linux 8 - $basearch # It is much more secure to use the metalink, but if you wish to use a local mirror # place its address ...
Troy Ward's user avatar
2 votes
1 answer
34 views

reg_replace in PostgreSql with pattern matching

I have below dataset, 1. '{SHEET,2730377,SHEET,5708283,DATA,3015937}' 2. '{SHEET,2730377,SHEET,5708283,DATA,3015937,DATA,0010965}' 3. '{SHEET,5708283,DATA,3015937,DATA,0010965}' 3. '{SHEET,5708283,...
Jim Macaulay's user avatar
  • 5,127
-3 votes
2 answers
36 views

What's the breakdown of the following regex? [duplicate]

^((?!ca-ct.mydomain)(?!ca.mydomain)(?!cats.mydomain).)*mydomain.com$ I got the above expression from a web.config file, it's supposed to filter out anything that contains ca-ct.mydomain or ca....
Carlos H's user avatar
  • 758
1 vote
1 answer
55 views

What are methods of parsing complex unstructured text from docx file into pandas?

I have a docx file with unstructured text that looks like the following: docx File Prep Northern Kitchen Number One K01-24-01-P01 $132,500 Background: None Project Description: Some long ...
Noa Mao's user avatar
  • 11
0 votes
1 answer
14 views

Regular expression to match image tag with empty source attribute?

I have bunch of files like these <IMG height=694 src="" width=201> and I would like to remove all of image tags with empty source attribute. Which regex I should use to match such ...
Patlatus's user avatar
  • 1,507

15 30 50 per page
1
2 3 4 5
17365