Skip to main content
Filter by
Sorted by
Tagged with
1 vote
0 answers
22 views

R: how to replace string with digit after capturing group [duplicate]

I need to transform strings like 333bis into 33300, so I set up a regex pattern like (\d{3})(bis), but I can't use \100 as substitute pattern, because it will be interpreted as "group 100". ...
eazyezy's user avatar
  • 131
0 votes
1 answer
72 views

replace pattern in lines with data find in another file with sed in BASH

I have 2 files: a channellist file and a global source file containing data of all channels. In the channellist there are f.i. these 2 lines; of course there are a lot more and all lines are starting ...
ni_hao's user avatar
  • 414
-1 votes
3 answers
70 views

How can I achieve this regex without a look ahead assertion?

I have regex which uses a look ahead assertion to match strings of the format {{ x }}. The regex is /(?<=\{\{\s)[^}\s]+(?=\s*\}\})/gm How can I achieve this without using a look ahead assertion?
williamsandonz's user avatar
1 vote
2 answers
58 views

Regex conditional non-capturing group

I am trying to extract the email`s username if the email is from a specific domain. otherwise, get the full email. I need the result to be set in Group 1. [email protected] => test test@example2....
Zeedia's user avatar
  • 1,453
0 votes
1 answer
26 views

None capturing groups in regex not working as expected

The following match patter does look for the character / not having a blank space before it, but having a blank or a dot or a line ending after it. >>> import re >>> re.search(r"...
buhtz's user avatar
  • 11.9k
6 votes
2 answers
195 views

Regex that match exactly 3 identical consecutive numbers

Good morning all, I want to make a regex that match 3 same consecutive numbers. It should match only 3 numbers in a row (separated by a space), the numbers should be identical. If there are less or ...
Rol Co's user avatar
  • 63
1 vote
1 answer
33 views

Extracting an optional project name in a fully optional pattern

I have this string "https://url/projects/x/flow/" and i want: if projects is existing in the string, capture x in a group named project_name if projects not existing in the string, then ...
Noura's user avatar
  • 59
2 votes
1 answer
45 views

allMatches not matching several groups exactly

I thought I knew about regex... Here's the situation: N-U0 U0-M1 M1-T9 T9-R10 R10-E19 E19-L100 L100-B I have a String that contains groups (let's call them transitions) separated by whitespace (may ...
GuiRitter's user avatar
  • 777
0 votes
2 answers
70 views

Regular Expressions in Javascript - Find Multiple Lines of Text After a Tag

I have the text below stored in the variable description: This is a code update Official Name: None Pub: https://content.upcodes.co/viewer/washington/wa-mechanical-code-2021 Agency: Reference: ...
alyssaeliyah's user avatar
  • 2,254
1 vote
2 answers
100 views

Regex: Only the first match of word after a given word is returned

I have a test string "apple search from here apple, banana, apple." and the following RegEx (?i)(?<=search from here\s)(\bapple|banana|orange\b)(\s+(\bapple|banana|orange\b))* I'm getting ...
bigb055's user avatar
  • 308
1 vote
3 answers
120 views

Conditional matching complex regex in capturing group

I am writing a regex for my git commit-msg hook and can't deal with the last part. This is my regex /^GRP\-[0-9]+\s(FIX|CHANGE|HOTFIX|FEATURE){1}\s(CORE|SHARED|ADM|CSR|BUS|OTHER){1}\s-\s.+/ My commit ...
Norayr Ghukasyan's user avatar
1 vote
1 answer
45 views

How do I fix my capturing groups to capture parts of a string of numbers?

As a new programmer, I am working on a problem that tells me to turn an array of 10 ints into a formatted string phone number that looks like this: (999) 999-9999. I am getting an error/issue with ...
Liam Barry's user avatar
2 votes
2 answers
66 views

Javascript Regex capture group with at least 1 non-digit of two forms: delimited by space and enclosed in quotes

I'm trying to category_id for purely numeric values, this works. I need to also capture category_name. For category_name, I need to capture until space or include space if it started with a double ...
James Risner's user avatar
  • 5,876
5 votes
3 answers
329 views

In Perl, is there a limit to the number of capture groups in a Regular Expression?

Is there a limit to the number of capture groups in a regular expression? I used to think it was 9 ($1 ... $9), but haven't found anything in the perlre docs to confirm this. And in fact, the ...
livefree75's user avatar
5 votes
3 answers
152 views

How to match all keys and values from a custom serialized object format?

I am trying to pick out all values from an object I have in string form. I have created the regular expression, but I am still having issues with not being able to remove the quotes and have hit a ...
Oli C's user avatar
  • 1,168
0 votes
2 answers
72 views

Capture the text using regex

I have a text where I need to capture the second group Response on your Property Listing Dear Rahul Bond, A user is interested in your Property, ID 62455995: 2 BHK , Multistorey Apartment in Raheja ...
Code Guy's user avatar
  • 3,190
0 votes
1 answer
469 views

Regex capture group within if statement in Java

I'm facing a stupid problem... I know how to use Pattern and Matcher objects to capture a group in Java. However, I cannot find a way to use them with an if statement where each choice depends on a ...
lennelei's user avatar
0 votes
1 answer
339 views

Preg_replace() to add to string using non-capturing group

I have a piece of HTML markup, for which I need to add a specific CSS rule to it. The HTML is like this: <tr> <td style="color:#555555;padding-top: 3px;padding-bottom: 20px;">In ...
Faye D.'s user avatar
  • 722
0 votes
1 answer
70 views

Where can I found Start Capturing Button in Internet Explorer?

I am reading 'Build RESTful APIs with ASP.NET Web API' article. I keyed F12, opened Developer Tools window in Internet Explorer but I could not find Start Capturing button. Can you please tell me how ...
ehs2020's user avatar
  • 13
-1 votes
2 answers
552 views

How to extract content in between an opening and a closing bracket?

I am trying to split a string into an array of text contents which each are present within the [@ and ] delimiters. Just characters in between [@and ] are allowed to match. Being provided with a ...
Sonali's user avatar
  • 3
1 vote
3 answers
174 views

Perl: Capturing variable cannot be set undef?

I have several regexp with capturing and obviously the capturing variable retains the value of the last valid capturing: # Two scalars to use for regexp $x = 'abc'; $y = 'def'; # first regexp $x =~ ...
giordano's user avatar
  • 3,102
-3 votes
1 answer
97 views

How to parse and distinguish different and varying arguments of a user command with a regular expression?

I'm trying to interpret user commands as dash optional flag. {run -o -f -a file1 file2} Something like this: /{run (-o|-f) (\w+) (.+?)}/g; Is very limiting with only 1 choice of flag. I'm looking ...
Harry's user avatar
  • 54.6k
1 vote
1 answer
102 views

Capturing Arbitrary Multiple Groups with Regex

I am trying to use regular expressions in Java to capture data from the following string: SettingName = "Value1",0x2,3,"Value4 contains spaces", "Value5 has a space before ...
Derek McCants's user avatar
2 votes
4 answers
613 views

Use just regexp to split a string into a 'tuple' of filename and extension?

I know there are easier ways to get file extensions with JavaScript, but partly to practice my regexp skills I wanted to try and use a regular expression to split a filename into two strings, before ...
AncientSwordRage's user avatar
0 votes
1 answer
335 views

Regex - match after sequence of characters

I'm trying to create a regex that matches either a 4, 5, or 6 digit number. If the first characters are zeros, only the last 4 digits should be matched or any characters greater than zero if 5 ...
Riceman's user avatar
  • 45
-2 votes
2 answers
91 views

Regex - Capture after 2nd occurance of character

I have a list of numbers 1.01.01.01 1.01.01.02 1.01.02.03 I need to add 1 to the number after the 2nd occurance of '.0': 1.01.02.01 1.01.02.02 1.01.03.03 I am using javascript. I have tried a few ...
Brendonius's user avatar
0 votes
0 answers
241 views

REGEX: how to capture terminal flags and arguments?

I'm trying to do some custom terminal flags and arguments, hoping to learn something new, and I feel something is missing, here is what I tried: /(?<flag>-{0,2}[., a-z0-9_-]*)(?<=\s*)(?<![-...
mr.xed's user avatar
  • 118
2 votes
1 answer
544 views

Javascript regEx to remove all parentheses except between special characters

I need a regEx to remove all ( and ) from a string, except those between two @. Example: ( [15] == @value 1@ || [15] == @value 2@ ) && ( [5] == @value 3 (ignore these)@ || [5] == @value 4@ ) ...
LauraEld's user avatar
  • 349
-1 votes
1 answer
258 views

Intellij Search Regex, select specific capture group

I'm playing regex with intellij for the moment and I want to know if it's possible to use capture to select all occurrence of a specific group. 12 330 13 450 1223 870 1213 900 regex: (^\d+) (\d+) ...
MaskedHawk's user avatar
1 vote
1 answer
40 views

RegExp How to link matching beginning/end strings for search/replace?

I have an XML file and need to find and replace all occurrences of a certain pattern enclosed between either of two pairs of tags, but not mixed between them. Example a) <CnlNum>548</CnlNum&...
Sergio's user avatar
  • 124
0 votes
1 answer
119 views

Identify which capturing group was matched in the evaluated string using regex

Hallo I'm new with regular expressions and im getting a hard time figuring out how to get the group that was matched in the evaluated string using regex in VBA. There are 4 or more different ...
Eduardo Massieu's user avatar
0 votes
1 answer
128 views

Why does backreferencing capturing groups work for multiple digit numbers in Java?

Let's say that you have a string: String string = "ab #1?AZa$ab #1?AZa$" You're trying to verify that the tenth is a non-whitespace character, and that the twentieth character is the same ...
Akshay S.'s user avatar
0 votes
0 answers
15 views

Regex for getting string between varying prefix & suffix [duplicate]

I am trying to extract a certain string from a set of filepaths that are formatted in one of two ways. Examples: Filepath A: /someprefix<DATE-TO-EXTRACT>/filename.txt Filepath B: /someprefix<...
user avatar
2 votes
1 answer
261 views

Regex, how to match string into two groups without excluding the first line

I tried using (?P<Time>.+)\,\s(?P<Station>.+), but it did not capture the first line. The sample strings aree: 9:21:13 AM 9:21:29 AM, TS729 9:21:33 AM, TS729 Tested at regex101.com:
Daniel's user avatar
  • 49
3 votes
4 answers
218 views

Why the line terminator `\r\n` causes groups not to be matched?

I'm working on text files with Windows line terminators (\r\n), on Linux with Perl v5.30. Something that I don't understand is why, with these text files, capturing groups don't match characters, ...
Marcus's user avatar
  • 5,225
1 vote
1 answer
746 views

How to achieve capturing groups in flex lex?

I wanted to match for a string which starts with a '#', then matches everything until it matches the character that follows '#'. This can be achieved using capturing groups like this: #(.)[^(?1)]*(?1)(...
Sourav Kannantha B's user avatar
0 votes
2 answers
1k views

Regex Capturing Group with alternative doesn't match

I have the following string where I want to match the valid <key>:<value> pairs. A valid <key> is anything with a non-whitespace character followed by : A valid <value> is ...
Frode Akselsen's user avatar
1 vote
2 answers
106 views

Why Perl regex capturing groups behave differently between `print` and arithmentic operations?

In Perl (v5.30.0), regex are evaluated as the captures, when used as parameters of print(): # Simplified example; the real case has more text, and the capture covers only part of it. echo $'1\n2\n3' |...
Marcus's user avatar
  • 5,225
0 votes
1 answer
245 views

Postgres regexp_replace: inability to replace source text with first captured group

Using PostgreSQL, I am unable to design the correct regex pattern to achieve the desired output of an SQL statement that uses regexp_replace. My source text consists of several scattered blocks of ...
WDock's user avatar
  • 3
0 votes
1 answer
105 views

Python regex capturing group extension

I am using named capturing groups using (?P<name>) with a list of verbs and word stems related to the coronavirus pandemic. import regex import pandas as pd data = {'id':[1, 2, 3, 4, 5], 'text':...
krasnapolsky's user avatar
1 vote
3 answers
660 views

Javascript regex: How to avoid a capturing group becoming "undefined"?

If I want to capture e.g. text that is either in round brackets or square brackets and use this regular expression: \[(.+)\]|\((.+)\) I get for the example "[test]" the results "test&...
Jomo's user avatar
  • 111
0 votes
2 answers
457 views

How does one capture a measure (number and/or unit) and a measured matter and always assures the same measure format/pattern?

I am just trying to understand javascript as I am a bit new to it and its such a power-full language. I wanted to know how to re-arrange words and numbers in a string so some words can always be in ...
Dilhan Bhagat's user avatar
0 votes
1 answer
161 views

How to split text into words while only capturing full stops and spaces that come after full stops?

I would like to split this text, "Tom works. Tom is a student. Bob is a student." into this, ["Tom", "works", ".", " ", "Tom", "is"...
Finn Buick's user avatar
1 vote
1 answer
52 views

Fix regex expression used to replace all \n and \r inside quotes

This might be hard to explain, I will do my best. I am currently working on a csv transform stream parser in nodejs, but I am struggling in replacing all \n's and \r's inside quotes (") that wrap ...
TiagoM's user avatar
  • 3,506
-3 votes
1 answer
250 views

Regex [] vs () in Python with respect to re.split() [duplicate]

What is the difference between [,.] and (,|.) when used as a pattern in re.split(pattern,string)? Can some please explain with respect to this example in Python: import re regex_pattern1 = r"[,\.]...
Vishwa Swaroop's user avatar
0 votes
4 answers
1k views

Multiple capturing groups within non-capturing group using Python regexes

I have the following code using multiple capturing groups within a non-capturing group: >>> regex = r'(?:a ([ac]+)|b ([bd]+))' >>> re.match(regex, 'a caca').groups() ('caca', None) &...
Felix's user avatar
  • 1,877
0 votes
2 answers
219 views

How to reorder a string (no matter how it is) using Python REGEX

I'm pretty newbie playing REGEX and I'm having a hard time... I'm trying to reorder a string using Python re. Here's a simple example, this is what I have: str = "one two three for" But the problem ...
Eduardo Franco's user avatar
0 votes
2 answers
267 views

Regex to capture the first 5 groups and last character

I'm trying to create a regex which will extract the first 5 characters and the last character in a string no matter the size of the string. For example For FOO:BAR:123FF:FOO:BARF:OO:BAR:1234 or FOO:...
Tv-Wonders's user avatar
2 votes
0 answers
142 views

regex with optional positive lookahead non-capturing group

How do I get the following code to not raise an AssertionError? I'm trying to capture the group with xyz in it and use an optional positive lookahead non-capturing group (?:</div>)?, but I can't ...
tommy.carstensen's user avatar
3 votes
3 answers
137 views

Regex recursion captured string

I have a problem with a regex that has to capture a substring that it's already captured... I have this regex: (?<domain>\w+\.\w+)($|\/|\.) And I want to capture every subdomain recursively. ...
Dugalle's user avatar
  • 33

1
2 3 4 5