Questions tagged [regex]

Regular expressions provide a declarative language to match patterns within strings. They are commonly used for string validation, parsing, and transformation. Since regular expressions are not fully standardized, all questions with this tag should also include a tag specifying the applicable programming language or tool. NOTE: Asking for HTML, JSON, etc. regexes tends to be met with negative reactions. If there is a parser for it, use that instead.

0
votes
1answer
15 views

How do I use glob/regex patterns to rename files in terminal?

I am trying to create a quick way to change the filename format to rearrange the original file name. EXAMPLE: I have three files: 2019_12_10_Mike_Smith_item1.jpg 2016_06_24_John_Ward_item2.jpg ...
0
votes
1answer
22 views

Python, regex: find and replace all instances of “yyyy” except when in front of a period

I am trying to find a numeric string and replace it. For example, let's say "1998", and replace it with "1999" in all of the files in the current directory. However, I do not want to conduct this ...
0
votes
2answers
17 views

separate (dplyr) with key in-between specific characters (after space and before capital letter) [duplicate]

I want to dplyr::separate on a minus (-) that has to be after a space and before a capital letter. My regex [\s]-[A-Z] includes the space and capital letter, hence removes by separating. I only want ...
0
votes
1answer
27 views

Regex for replacing commas only within square brackets

I have a text file and it contains comma separated strings. But some of the strings separated by commas are of the form [*,*,*,...]. So for example: "Hello", "Goodbye", ["Yes", "No", "Maybe], "...
0
votes
0answers
9 views

Remove CDATA from XML with regex in Windows CMD (powershell)

I am working with some XML data and I am stacked trying to remove CDATA in XML. I tried many ways, and it seems the simplier is by replacing all patterns hey <![CDATA[mate - number 1]]> what's ...
1
vote
1answer
17 views

Is my R Regular Expression matching correctly?

I've struggled with regular expressions in general and recently wrote one that I think is working correctly, but I'm not sure. My question to anyone who takes the time to review my code below - is it ...
1
vote
1answer
29 views

Regex absolute begginer: filter alphanumeric

I'm playing codewars in Ruby and I'm stuck on a Kata. The goal is to validate if a user input string is alphanumeric. (yes, this is quite advanced Regex) The instructions: At least one character ("" ...
-1
votes
0answers
32 views

how to use variables in Regex

I am trying to write a function that checks for a strong password. The password must contain one upper case, one lower case,a number and must be 8 characters long. import re def checker(): while ...
0
votes
1answer
41 views

Remove a character in the middle of the string

Suppose we have the lines 1234H242343,6334H345345, etc. I need a regular expression to get the strings 1234242343,6334345345, etc. The character may vary (not always H), but in this case, the H ...
1
vote
0answers
19 views

Groovy/Java - Issue copying files with parentheses in its path

I currently have a script that copies files from a source directory to a target directory through regex inclusions and exclusions, however when the path contains parentheses the file will not copy. ...
1
vote
2answers
20 views

Find a certain word in pipe seperated values

I am trying to figure out how to match a certain word in pipe separated messages. Ex: 20190614|3|method|user|/test/xyz/1.1|400|0 How do I check every message which starts with "/test" in the 5th ...
0
votes
1answer
19 views

Setting minimum and maximum value using regex

I want a textbox to have a value between 0 and 24. However the below pattern does not seem to be working. Regex regex = new Regex("^([0-9]|1[0-9]|2[0-4])$");
1
vote
3answers
23 views

Regex for extracting exactly 10 digits from String

I have multiple formats of strings from which I have to extract exactly 10 digit number. I have tried the following regexes for it. But it extracts the first 10 digits from the number instead of ...
-1
votes
0answers
8 views

deleting multiple lines starting with a keyword

I have a .bib file from which I want to delete all the editor entries. The editor names are on different lines (which gives me the problem with my limited knowledge of regex) as follows: editor =...
-1
votes
1answer
23 views

Regex In PHP That Has A Static String With Variable Numbers

I can't wrap my head around regex. Let's say I have this string: SELECT mx_posts.ID FROM mx_posts INNER JOIN mx_postmeta ON ( mx_posts.ID = mx_postmeta.post_id ) WHERE 1=1 AND ( ( YEAR( mx_posts....
1
vote
3answers
28 views

Coalesce columns based on pattern in R [duplicate]

I have combined data sets in R, and each data set may use a different column name for the same data. I need to use a regular expression to identify the names of the columns I need to combine, and then ...
0
votes
0answers
25 views

Regex for specific input with only numbers and delimiters (“,” and “;”) are allowed

I would like to validate an input (of type String) which have delimiters (only "," or ";") followed by a number of specific length e.g. input1=444554; 445148, 41412; and input2=414454, 784554, etc.
0
votes
1answer
16 views

document level regex

I am looking to create a system that extracts blocks of code from C++ files. For example, if I wanted to extract every while loop, I would look for a pattern that begins with while and ends with }. ...
0
votes
0answers
12 views

Regex match line but get part of this line [duplicate]

Import complete Summary: 4 XXX were created 0 XXX had bbb created 0 XXX had a ccc created 2 XXX had ddd created and I need to catch line: 4 XXX were created but I need as a result just a number 4 ...
0
votes
0answers
20 views

Checking 'validity' of expression string based on 'rules' in <input>/<mat-select>

I need to 'validate' (not evaluate) a string input/mat-select that is a 'proper' combination of predefined 'fields', 'operators', 'values', and/or 'keywords to create a 'query string'. It's not unlike ...
0
votes
1answer
20 views

I want to build regex, which gives me back specific string

I have an array of strings. Now I have to build a regex, which gives me a string, which starts with a single letter, then \ , then 4 digits. I tried the following code. namespace ConsoleApplication ...
0
votes
0answers
18 views

Regex in ansible to check for multiple lines with same prefix

I am checking if few lines are present in a file using ansible. These lines have a common prefix and if all the lines are present in the file i will print "YES" otherwise "no" --- - hosts: localhost ...
-1
votes
0answers
23 views

Create blacklist regex expression using SQL syntax [on hold]

How to create blacklist regex expression for SQL to filter unwanted messages with specific keywords like "porn", "sex" etc
1
vote
2answers
22 views

Highlighting lines that contain a phrase using regex

I'm highlighting lines that contain a certain phrase using regex. My current highlight function will read the whole text and place every instance of the phrase within a highlight span. const ...
1
vote
0answers
21 views

How to fix 'SyntaxError: invalid regular expression' in React Router regex path

I am building a single page React app in ReactJS using react-router, and want to show a certain component only when in root (path="/"). To do this I am trying to use regex in the Route path. However, ...
-1
votes
0answers
15 views

What's wrong with the below regular expression? [duplicate]

I'm trying to validate UK Postcodes that don't meet the standard ruling, using a regular expression, but the one I'm using (below) isn't working and I've spent too long staring at it that it's no ...
0
votes
0answers
18 views

How to make regullar expresion case insensetive in MVC [duplicate]

I have a server side validation on MVC RegularExpression Attribute [RegularExpression("^((?!spbhelix|SPBHELIX).)*$", ErrorMessage = "")] I want to make it case insensetive, How i do it?
0
votes
1answer
23 views

How to limit Regex length based on its most outer capturing group and not on any special character set

I am trying to implement regex for hostname with length range 1-5 But my regex is accepting any string with infinite lengths This particular regex could not be done by quantifying individual ...
-1
votes
1answer
24 views

Extract sub-string from string using regex [duplicate]

I'm kinda new to regex, so I have the following string: [[ChromeDriver: chrome on LINUX (ff108507ea7a3598104c728cc453f299)] -> xpath: /html[1]/body[1]/div[3]/div[1]/header[1]/div[1]/div[1]/div[1]/...
0
votes
1answer
26 views

Multiline pattern with specific ending

I my trying to match some multiline pattern, which has specific sequence ending of last line. I'm using re.DOTALL | re.MULTILINE to match multiline, but it doesn't catch end of lst line which I want. ...
-2
votes
2answers
36 views

how to ignore commas inside a word and return it as one word in a string

I have a string that contains words separated by comma. in that string there is one name "v,i,n,t,a,g,e" that is written with a comma between the characters. I want a know how I can tell python that ...
1
vote
2answers
31 views

Hashtag followed after by a regular text

I want to check if a hashtag is followed by a regular text or another hashtag in a python string. for example for the case: "my adjectives names #Day #Night which are in the description" , I get ...
0
votes
2answers
34 views

Regular expression to find both non-null and NULL values

My store procedure is using regular expression as a parameter to filter a set of rows: DECLARE @filter = '%' SELECT * FROM TableA where ColumnA like @filter Value '%' extracts all non-null values ...
1
vote
3answers
20 views

What is the RegEx to test for a compliant FATCA Global Intermediary Identification Number (GIIN)?

This is the spec for the FATCA GIIN. 19 digits, alphanumeric and only uppercase, in 4 groups, each separated by a compulsory dot/period: XXXXXX.XXXXX.XX.XXX First two groups are alphanumeric ...
-4
votes
4answers
29 views

Why asterisk put in front not working in `re.match()` and how to make it works? [on hold]

To make my program robust, I want to allow user specify list of regex like: 'first_name','*second_name*' in argument, split by comma manually after retrieve the argument string from argparse. But I'...
-1
votes
1answer
23 views

How to split text in one column of pandas data frame to required format(three columns of dataframe )

Given data, I need to separated into three columns as Name, Date, Type IN data frames: The data: ANNAPOLIS INDUSTRIAL LOAN CO - Aug-2002 - Non-Procurable Miscellaneous Non-Procurable Royalties ...
0
votes
0answers
23 views

Weird interaction between regExp and array.filter() method, curious about root cause [duplicate]

While trying to filter out array that contains nested objects in it by testing one of the keys with regular expression I stumbled upon really weird interaction. Simplified version of my data: ...
-2
votes
1answer
23 views

How to match numbers greater than 2048 with regex

I need to match numbers greater than: 1. 2048 2. 32768 My current regex for 2048 is: ([2-9][0-9][4-9][8-9]|[1-9]\d{4,}|[3-9]\d{3,}) But it is not matching 2077. Help me out here. Also I am not able ...
0
votes
0answers
12 views

Regex throwing error on Edge, Firefox, Safari browsers (Ionic 4 Angular) [duplicate]

I am working on Ionic 4 project, and the issue is i wrote a regex code to distinguish Youtube video ID from a given link. this is working fine with Chrome and Android Build. but on Firefox, Safari, ...
0
votes
0answers
21 views

The Regex is return false in any version PHP

I cant find why /^(\+994|994|0)(50|51|55|70|77)([0-9]{7})$/ type of regex return false in case "n": // Azerbaijan(for now) phone numbers if (!preg_match("/^(\+994|994|0)(50|51|55|70|77)([0-...
-1
votes
1answer
30 views

Find “real” formula for a formula group

I am trying to find the "real" formula of a group. For example, these are the formulas =If(A$4>$A1,"Long","Short") =If(B$4>$A1,"Long","Short") =If(A$4>$A2,"Long","Short") =If(A$4>$A$2,"...
0
votes
0answers
10 views

Regular expression matching nested comments *too much*

I have a RegExp that I use in my Lexer function to see if there are any nested comments before i compile my code. This is the regex I use in my code: /\/\*[\s\S]*(?:\/\*[\s\S]*)?\*\/[\s\S]*\*\// \/ ...
3
votes
1answer
23 views

Regexp didnt find the match

created a regexp for a date with time, formatted like this 25.06.19 / 16:30 I created following regexp. ^[0-9]{2}\.[0-9]{2}\.[0-9]{4}\s.\/\s.[0-9]{2}\:[0-9]{2}$ the result should deliver above ...
1
vote
1answer
27 views

How format currency with javascript and validate

i'm using react and wan't to format and validate input value. my use cases are: 1- in input will enable writing only digits and dot [.] 2- value can be max 1000 3- if user will write eg: if 200 ...
-2
votes
0answers
15 views

How to create Regex for allowing few special characters while restricting other special characters in Angular? [duplicate]

I am doing form validations in Angular 7. There, I have one form field in which I need to allow following special characters: ( ) - _ + = [ ] { } | : ; < > . , While I have to restrict ...
0
votes
0answers
11 views

edge effect ( unwanted effect ) regex remove numbering

I'm trying to remove Numbering ( both Roman and Basic numbering ) from some text , I'm using the following Regex which is pretty good at generalizing and seems to match most of the patterns of ...
-2
votes
0answers
12 views

I want to convert Facebook's URL,I want to convert Facebook's URL and get the following results [on hold]

I want to convert Facebook's URL,I want to convert Facebook's URL and get the following results https://www.facebook.com/pg/Electronic-gadget-359743878154253/posts/?ref=page_internal https://www....
1
vote
1answer
16 views

reg match to search a string informatica with delimiter '/'

I have a string column with the below sample data. 1) ABC/DEF/003 - This is for testing 2) XYZV/T&X/ABC/004 - This is for testing 3) ZXC/004/007 - This is for testing 4) This is testing ...
1
vote
1answer
32 views

using sed or grep to extract word

I get only white space when I try to extract the ID by code: grep "latest" sometextfile | sed 's/.*latest\([\s*]*\).*/\1/' REPO SAL ID ...
-2
votes
1answer
25 views

Value not compliant with regex [duplicate]

I have String value and I want to valid it using a regex and still get an error Value doesn't comply with format: HK_CAT-B ValidValue REGEX[[A-Za-z-,'.\s]] This the value that I want to valid : ...