capturing-group Questions
6
Solved
I would expect this line of JavaScript:
"foo bar baz".match(/^(\s*\w+)+$/)
to return something like:
["foo bar baz", "foo", " bar", " baz"]
but instead it returns only the last captured match...
Romeyn asked 21/8, 2010 at 14:8
2
Solved
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...
Gunilla asked 23/7, 2023 at 1:56
8
I want to match a regex like /(a).(b)(c.)d/ with "aabccde", and get the following information back:
"a" at index = 0
"b" at index = 2
"cc" at index = 3
How can I do this? String.match returns li...
Lucrative asked 10/4, 2013 at 19:8
3
Solved
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 follo...
Powerdive asked 14/12, 2022 at 15:29
18
Solved
How are non-capturing groups, i.e., (?:), used in regular expressions and what are they good for?
Gussiegussman asked 18/8, 2010 at 13:17
5
Solved
I have a list of words:
bau
ceu
diu
fou
gau
I want to turn that list into:
byau
cyeu
dyiu
fyou
gyau
I unsuccessfully tried the command:
:%s/(\w)(\w\w)/\1y\2/g
Given that this doesn't work,...
Extend asked 11/11, 2013 at 8:43
4
Solved
re.sub('a(b)','d','abc') yields dc, not adc.
Why does re.sub replace the entire capturing group, instead of just capturing group'(b)'?
Fibrin asked 8/2, 2017 at 4:10
4
Solved
I want sed to omit all non-matching lines, and only output the replaced string (of the single/multiple intended line/s).
In other words: I've got a hay stack, and only want the needle returned, no...
Digitalism asked 4/4, 2011 at 21:3
5
Solved
I have the following regular expression (regex) in my urls.py and I'd like to know what it means. Specifically the (?P<category_slug> portion of the regex.
r'^category/(?P<category_slug>...
Outcry asked 3/11, 2011 at 0:20
4
Solved
After hours of searching I decided to ask this question. Why doesn't this regular expression ^(dog).+?(cat)? work as I think it should work (i.e. capture the first dog and cat if there is any)? Wha...
Suspiration asked 28/2, 2015 at 14:4
3
Solved
This is a markdown document example.md I have:
## New language
Raku is a new language different from Perl.
## what does it offer
+ Object-oriented programming including generics, roles and mul...
Monometallic asked 20/7, 2019 at 17:53
4
Solved
Hard to word this correctly, but TL;DR.
I want to match, in a given text sentence (let's say "THE TREE IS GREEN") if any space is doubled (or more).
Example:
"In this text,
THE TREE IS GREEN sh...
Tympanum asked 8/7, 2019 at 19:32
5
Solved
Let's say I have this code:
val string = "one493two483three"
val pattern = """two(\d+)three""".r
pattern.findAllIn(string).foreach(println)
I expected findAllIn to only return 483, but instead, ...
Oversweet asked 16/6, 2010 at 5:29
7
Solved
I am writing a set of RegExps to translate a CSS selector into arrays of ids and classes.
For example, I would like '#foo#bar' to return ['foo', 'bar'].
I have been trying to achieve this with
"...
Selfinterest asked 2/6, 2012 at 18:16
2
Solved
I use python regular expressions (re module) in my code and noticed different behaviour in theese cases:
re.findall(r'\s*(?:[a-z]\))?[^.)]+', 'a) xyz. b) abc.') # non-capturing group
# results in ...
Decarbonate asked 4/2, 2013 at 17:46
2
Solved
I would expect these lines of C#:
var regex = new Regex("A(bC*)*");
var match = regex.Match("AbCCbbCbCCCCbbb");
var groups = match.Groups;
to return something like:
["AbCCbbCbCCCCbbb", "A", "bC...
Clem asked 4/10, 2016 at 6:57
1
Solved
I'm attempting this challenge:
https://regex.alf.nu/4
I want to match all strings that don't contain an ABBA pattern.
Match:
aesthophysiology
amphimictical
baruria
calomorphic
Don't Match
an...
Beatabeaten asked 30/9, 2015 at 9:16
1
Solved
I'm trying to parse a string using one regular expression pattern.
Here is the pattern:
(\")(.+)(\")\s*(\{)
Here is the text to be parsed:
"base" {
I want to find these 4 capturing groups:
...
Unreasonable asked 19/7, 2015 at 8:14
2
Solved
How can I get the content for a group with an asterisk?
For example I'd like to pare a comma separated list, e. g. 1,2,3,4,5.
private static final String LIST_REGEX = "^(\\d+)(,\\d+)*$";
private ...
Deposal asked 15/9, 2014 at 23:19
2
Solved
As the title suggests, I'm trying to retrieve the domain from a string using javascript regular expression.
Take the following strings:
String ==> Return
"google" ==> null
"google.com" ==&...
Rusel asked 15/8, 2014 at 8:4
3
Solved
I'm looking for a regex that will match ad-hoc groups of characters of certain length only if all its characters are unique.
For the given string example:
1231322132313123211121221211112223332...
Good asked 25/10, 2013 at 16:34
2
Solved
I have the following regular expression in two different languages that produces the same odd results (javaScript and Flash). What I want to know is not how to fix it, but why the behavior is occur...
Nebuchadnezzar asked 30/6, 2013 at 18:45
3
Solved
I need to match following statements:
Hi there John
Hi there John Doe (jdo)
Without matching these:
Hi there John Doe is here
Hi there John is here
So I figured that this regexp would work:
...
Collen asked 1/8, 2012 at 14:21
1
Solved
I need to convert data from a spreadsheet into insert statements in SQL. I've worked out most of the regular expressions for using the find and replace tool in SSMS, but I'm running into an issue w...
Bolus asked 29/3, 2012 at 17:32
1
Solved
I want to get attached named group.
Source text:
1/2/3/4/5|id1:value1|id2:value2|id3:value3|1/4/2/7/7|id11:value11|id12:value12|
Group1:
1/2/3/4/5|id1:value1|id2:value2|id3:value3|
Sub groups:
i...
Dezhnev asked 7/5, 2011 at 17:4
1 Next >
© 2022 - 2024 — McMap. All rights reserved.