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.

Filter by
Sorted by
Tagged with
0 votes
5 answers
78 views

Wrong regex in C#

I have this string input in C# string InputNames = "\"James Alkaba\", \"Carl James\", \"Thomas Merk\""; I want to use regex to make this string look like: ...
OxyK's user avatar
  • 1
0 votes
0 answers
13 views

Fluentd error log config file format RegEX

My error: [warn]: #0 pattern not matched: "Oct 3 17:23:12 dc2prepzeebe03 broker[12925]: {\"severity\":\"DEBUG\",\"logging.googleapis.com/sourceLocation\":{\"...
Jeyhun F. Aslanov's user avatar
-2 votes
0 answers
16 views

C++ Reg ex group repeating pattern [duplicate]

Let's say I have this string (i, j, m, [...]) and I want to get each letter or word as a match result. The [...] means that there could be an unlimited number of further letters or words. How could ...
t-Boned's user avatar
-4 votes
0 answers
32 views

What's the right regex? [closed]

have this string input in C# string = ""James Alkaba", "Carl James", "Thomas Merk" I want to use regex to make this string look like: James Alkaba,Carl James,Thomas ...
JoshGarrison's user avatar
0 votes
1 answer
26 views

Finding rows with invalid regular expressions in MySQL

I have a table with a column that contains a regular expression used to match rows from other tables. I then need to query like this SELECT st.id FROM some_table st WHERE '1234' REGEXP st.regexp; As ...
Dennis Pettersson's user avatar
2 votes
2 answers
44 views

Count occurences of substring in string

I'm trying to count the number of times a string, say AAA occurs in a longer string, say AAAA. The answer in this case is clearly 2: AAAA AAAA None of these work as I would expect: stringi::...
fugu's user avatar
  • 6,437
-1 votes
0 answers
27 views

Regex to extract Google Sheet URL where the ID contains a hyphen [closed]

I use the following regex to identify multiple GSheet URLs in a string (using Google Apps Script/Javascript): var urls = str.match(/\b(https:\/\/docs\.google\.com\/document\/d\/)[-\w\\]+\b/g) However,...
Andrew Roberts's user avatar
-1 votes
0 answers
10 views

How to read these regex expressions and how to understand what strings are these looking for? [duplicate]

After extensive search I am unable to find explanation for How to read these regex expressions and how to understand what strings are these looking for? My main goal is to fetch the branches from git ...
Cloud_Engineer's user avatar
-2 votes
1 answer
25 views

I am getting an error when issuing commands to my custom python command prompt

Since I don't know where the problem originates, I shall post all the code (not much). It is a value error: This is my main.py from cmdClass import * import re import os mainObject = Cmd() while True:...
Sam64710's user avatar
-1 votes
0 answers
25 views

Regex where 2 consecutive alphabet allow along with only -

I want regex in java where 2 consecutive alphabet allowed one hyphen at any location Note :- more than one hypen not allowed Only 2 consecutive alphabet allowed if more than 3 it won't allow Without ...
Sandeep Singh's user avatar
-1 votes
1 answer
24 views

How to extract value of a currency in a particular format from Google Sheets using REGEXEXTRACT [duplicate]

I have some prices in few cells in google sheet formated as INR : ₹ 72,990 ₹ 446,390 I want to extract numerical values without '₹' and ',' as follows: 72990 446390 I tried using =REGEXEXTRACT(A4, &...
Kuldeep Kumar's user avatar
-1 votes
0 answers
40 views

What is the name of the python library that matches patterns using f-strings? [closed]

I had once read, through an obscure post on LinkedIn, about a python library that matches pattern using f-strings. For example, the pattern string {} world would match anything in place of {}, so ...
Sam2Khat's user avatar
-3 votes
1 answer
74 views

Trying to extract exact, lowercase word using JS regex [closed]

Overview I am writing a small bit of code to find specific words and replace them using JS by wrapping them with a span tag. At present, I have tried a number of methods. Strangely, what I have ...
twelfth's user avatar
  • 69
0 votes
4 answers
65 views

Filter pattern with float values with python regex [duplicate]

I am using python 3.8 and regex to filter the string with numeric values. I need help in filtering decimal values with the string using re.search. I tried with [\d.] pattern but that does not help to ...
Kishan's user avatar
  • 354
-2 votes
0 answers
19 views

Python dataframe string colum replace last occuring k-character [duplicate]

I have a dataframe with string column like this: index 26NYTAk11v34 43RATIk4v34 72MI-k4k6v34 27Io-kTk2v34 17Mykok4v34 In the index column, I want to replace the last occuring k value with *T. If K ...
Yash's user avatar
  • 283
0 votes
1 answer
46 views

String validation using regular expressions

I need to create a regex for 3 rules. The string can start with a letter or _. No numbers are allowed before the letter or _. The _ can be added in any place. Using special characters or spaces is ...
Asaw's user avatar
  • 11
0 votes
1 answer
32 views

Text cleanup in snowflake

I have a column in a table that contains data about any updates related to changes about a company in the below format - #=============#==============#================# | Company ID | updated_at | ...
Abhigyan Sarma's user avatar
-3 votes
0 answers
31 views

Backslash regex issue in Javascript? [duplicate]

Can someone tell me how to overcome this situation? 'fingerprints\fingerprint.svg'.match(/([a-zA-Z]|[0-9])+[\.]{1}(\w+)/g) this code returns ['ingerprint.svg']
Gökhan Korul's user avatar
-1 votes
4 answers
81 views

Regex to find same consonants anywhere in a word, not just consecutively [duplicate]

What is a regex which finds how many words in a text corpus have the same consonant appearing more than four times? As an example, the German word Sonnentrunkenheiten has 6 n. This regex ([b-df-hj-np-...
Patrick Huber's user avatar
1 vote
2 answers
82 views

JavaScript RegExp Multiple Named Capture Groups

I would like a RegExp to capture the number of pics, vids and writings in a string. That string could contain one, two, all or none of the categories. This is the closest I've got to those results. ...
DataZombies's user avatar
2 votes
1 answer
36 views

XSLT Regex in replace()

I am having an issue when trying to replace multiple spaces in a piece of text within an XSLT transform. I feel like I am overlooking something simple, but I'm just not seeing it. Simple example: <...
twfurst's user avatar
  • 215
2 votes
2 answers
66 views

Regex to match Postgres "operator name" rules

I'm trying (and failing) to write a JavaScript regular expression to match a PostgreSQL operator name, defined in the docs as: An operator name is a sequence of up to NAMEDATALEN-1 (63 by default) ...
Tim Needham's user avatar
-1 votes
1 answer
37 views

When applying a Regex with groups to a string, is there a way to tell if there are multiple ways that those groups can be matched?

As an example, I have the following regex: ^(.*)[AB]+$ which I am matching against the string ABBA The entire string ABBA is a match for the regex, that is correct, however I am only able to get the ...
user1538050's user avatar
-2 votes
2 answers
54 views

PostgreSQL - How can I check if string A contains number B using regex?

I want it to match only if the number B is not inside a bigger number. e.g. I dont want it to match this: A = "12345" B = 234 I want it to match this: A = "94, 234, 88" B = ...
Michal Novák's user avatar
-1 votes
0 answers
37 views

Regex lookbehind exact alternative [duplicate]

I have a regex with a negative lookbehind that is not supported browsers like safari below 16.3 and before ECMAscript 2018 /(?<!\S)([@@][a-zA-Z0-9_]+)(?![a-zA-Z0-9_@@])/ I want the exact ...
Shant Kevorkian's user avatar
-1 votes
0 answers
22 views

Using regular expressions and negative lookahead to detect month names and stems [duplicate]

I have a vector of alphanumeric strings that sometimes contains month names (e.g., "November") and stems (e.g., "Nov") and some words that contain the stem but do not indicate the ...
identic0n's user avatar
-1 votes
0 answers
11 views

Bash regex doesn't match on numbers separated by dots [duplicate]

I have the following script, I want to be able to match one of the following strings: main or any of the following patterns: \d.\d{1,2}.\d E.g., 1.02.4 7.4.9 and any other combination. If REF contains ...
DavSev's user avatar
  • 1,033
0 votes
0 answers
33 views

query selector regex to match /blahblah/ [duplicate]

I got a page that contains many a tags. I need to select those who has "/[a-z]/" pattern in their href prop. I wrote something like this: document.querySelectorAll("a[href='/a-z+/']&...
Behzad Safamanesh's user avatar
-1 votes
0 answers
21 views

Regex pattern for a range of numbers excluding specific numbers (newbie) [duplicate]

I am trying to create a regex pattern for to be used in a plugin which does the below. Kindly note that I am newbie and don't have coding experience: Range: 1 to 1500 Excluding numbers: 5, 10, 78 ( I ...
Pat's user avatar
  • 1
-1 votes
0 answers
47 views

How to match a regex in Ballerina? [duplicate]

I’m working on a Ballerina project and I’m trying to do a contains check as follows,

 string key = "ownerEmail"; string url3 = "/guest-wifi-accounts/{ownerEmail}"; io:println(url3....
Mindula's user avatar
  • 71
-1 votes
1 answer
66 views

Extract value of a field form json-like string using PHP Regex

I need to extract value of a json field by regular expression, (I can't use json decode). let's say for this string: "url":"http://stackoverflow.com/orwell", "domain":&...
Mohammad Salehi's user avatar
1 vote
1 answer
33 views

Regex that matches files with two or more unique extensions

I am trying to create regex that matches files with two or more extensions, but I want to ignore duplicate extensions. Examples of results I want: videogame.exe.exe - Don't match unknown.pdf.exe ...
zombhe's user avatar
  • 13
0 votes
4 answers
49 views

How to filter a numeric value with spaces using regex in python

I am new to python and using version 3.8. I use regex to filter strings, special characters and numbers from a string. There are spaces in between characters and numbers and i try to filter them. I am ...
Kishan's user avatar
  • 354
0 votes
2 answers
38 views

htaccess rewrite condition 404 all querystring only on index page

i was trying to protect the main page because on google console my report on a querystring is visible like this example: https://example.com/?s=something.g i would like to 404 all querystring only on ...
Dhon Collera's user avatar
1 vote
3 answers
46 views

Return Whole Match instead of capturing group (REGEXP BIG QUERY)

I am new in regular expressions and big query and I want to extract the age range from a string to define it as a variable in a table, so I did something like this: WITH example AS ( SELECT "...
DART's user avatar
  • 21
-3 votes
2 answers
45 views

Javascript replace regex wildcard with dynamic text

I need to extract text but some parts are dynamic and change This is my var htts://query1.data.site.com/v7/finance/download/MYTEXT?period1=1664641287&period2=1696177287&interval=1d&events=...
cicoria's user avatar
  • 27
0 votes
3 answers
56 views

How to write a generical REGEX expression to: Σ = {a, b, c}, L = {w ∈ Σ ∗ / the first symbol of w is equal to the last symbol of w}? [closed]

I tried ^(a|b|c)?(a|b|c)*\1$ and some variations but for some reason words like a or b aren't captured. Could you guys explain me why? I also don't get why in the expression ^(a|b|c)?(a|b|c)\1$ the ...
Gustavo Calanzani's user avatar
2 votes
4 answers
52 views

Regex parse multiple separate words and ignore double quotes

I'm trying to parse a string similar to the one below. This represents queries for a book. Multiple options are available to look for specific fields, so intitle: looks for something in the title of ...
mateoc15's user avatar
  • 531
-1 votes
0 answers
16 views

Regex pattern showing not all matching groups [duplicate]

I'm a python and regex newbie and could use your help. I have the following string from a log file: Sep 26 14:27:05 my-server-01 apache2[56789]: [error] AH00124: Request exceeded limit of 10 internal ...
Nicholas's user avatar
2 votes
6 answers
228 views

Regex series of optional matches with separator depending on state

I would like to accept user input in a series of patterns of major increments to minor increments of fluids. 1gal-1qt-2pt-2cup-5oz I need to enforce the order of unit suffix (gal->qt->pt->cup-...
NWoodsman's user avatar
  • 489
1 vote
2 answers
72 views

Delete a line that doesn't have an specific line above it

I had this rythimn game chart script TARGET(1 TIME(268466) TARGET(1 TIME(273333) TIME(278723) TARGET(1 TIME(306666) TIME(309492) TARGET(0 TIME(330005) However, I need that every line maintains a &...
Alexander López saldarriaga's user avatar
1 vote
3 answers
76 views

Regex to match if a following named group matches

^(?<foo>[a-z]+)?(?<bar>[1-9]+)?$ I need to match a whitespace if bar, which is optional, is present/match. If bar is not a match, no whitespace is needed. abc 100 is a match abc is a match ...
NWoodsman's user avatar
  • 489
0 votes
2 answers
65 views

Regex to find all class names from .css file

I am working on a ticket for an open source project. There are over 800+ css files, and I need to get all the class names from all these files, and then check all the HTML files for these class names. ...
Jessica's user avatar
  • 1,085
1 vote
3 answers
52 views

Regex unicode replacing spaces and Tabulators

I'm having trouble getting this regex replacement code to work "again" I believe this used to work in /net but it never worked in Expresso ( - meaning it might never actually worked properly)...
jorge corvallis's user avatar
-2 votes
0 answers
30 views

How to check whether a specific string enclosed in double quotes [duplicate]

I have four strings: Cox's Bazar is Beautiful "Cox's Bazar is Beautiful" "Cox's Bazar is Beautiful Cox's Bazar is Beautiful" How can I find the sentence that is enclosed in the ...
Shah Alom's user avatar
  • 1,037
-1 votes
2 answers
112 views

Regex pattern - couples' names

I am looking for a regex pattern that matches patterns like "Jane and John Smith" (I mean first-name and first-name last-name) in the middle of a text. It should not match "Jane Smith ...
Bahar S's user avatar
  • 419
0 votes
0 answers
57 views

Regex match a row copied from webpage

so if I copy a table to clipboard directly, it give the following result: Dirty1057 SUPQB 1 Occupied Checked Out (Unchecked) Priority (Unchecked) Linen Change DEP View Select Out of ...
Eric's user avatar
  • 53
0 votes
0 answers
15 views

Apache2 VirtualHost : deny root URL but allow path

I am using below to block accessing the root URL... and trying to only allow access if visited path or with anything after root domain... # Redirect root domain to a 403 Forbidden error <Location &...
Sajjad Hossain Sagor's user avatar
1 vote
1 answer
56 views

Regex to identify and extract structured information

I am parsing an unstructured text file that contains structured bits of information. It is straightforward to write a regular expression to identify and extract the structured strings. It seems like ...
Robert Cheatham's user avatar
-1 votes
2 answers
38 views

regex returns true but?

I have date field as YYYYMMDD, it's definition: zod.string().max(8).regex(new RegExp('^(19[0-9][0-9]|20[0-9][0-9]|[0-1][0-9]{3})(1[0-2]|0[1-9])(3[01]|[0-2][1-9]|[12]0)$')); and value 20001915 I mean ...
Tad's user avatar
  • 129

1
2 3 4 5
5186