capture-group Questions
5
Solved
I have the following regex:
\[([^ -\]]+)( - ([^ -\]]+))+\]
This match the following successfully:
[abc - def - ghi - jkl]
BUT the match is:
Array
(
[0] => [abc - def - ghi - jkl]
[1] => a...
Bellerophon asked 12/4, 2011 at 23:35
2
Solved
The following Perl code fails on the second attempt of dereferencing the capturing group "ext"
use strict;
use warnings;
foreach(qw/2.1 2/){
#foreach(@ARGV){
my $out= sprintf("%.2f...
Wideawake asked 3/7, 2023 at 16:11
17
Solved
I'm a regular expression newbie and I can't quite figure out how to write a single regular expression that would "match" any duplicate consecutive words such as:
Paris in the the spring....
Proverb asked 12/5, 2010 at 21:51
2
Solved
Are optional non-capturing groups redundant?
Is the following regex:
(?:wo)?men
semantically equivalent to the following regex?
(wo)?men
Gauze asked 19/7, 2015 at 10:57
5
Solved
I've got a regular expression with capture groups that matches what I want in a broader context. I then take capture group $1 and use it for my needs. That's easy.
But how to use capture groups wit...
Kimbrough asked 26/8, 2012 at 14:59
8
Solved
I'm porting a library from Ruby to Go, and have just discovered that regular expressions in Ruby are not compatible with Go (google RE2). It's come to my attention that Ruby & Java (plus other ...
Situs asked 27/5, 2015 at 13:17
2
Solved
I'm trying to figure out how I can repeat a capture group on the comma-separated values in this the following url string:
id=1,2;name=user1,user2,user3;city=Oakland,San Francisco,Seattle;zip=94553...
Toby asked 17/4, 2017 at 23:50
9
Solved
In R, is it possible to extract group capture from a regular expression match? As far as I can tell, none of grep, grepl, regexpr, gregexpr, sub, or gsub return the group captures.
I need to extra...
Stirrup asked 4/6, 2009 at 18:25
2
Solved
Im learning regular expressions, specifically named capture groups.
Having an issue where I'm not able to figure out how to write an if/else statement for my function findVul().
Basically how the...
Petula asked 12/10, 2018 at 3:29
4
Solved
Why is this code only spitting out the entire regex match instead of the capture group?
Input
@"A long string containing Name:</td><td>A name here</td> amongst other things"
O...
Aleron asked 25/7, 2011 at 21:6
1
Solved
I want to have multiple capture groups that can be optional and I want to access the strings they correspond to.
Something that looks/works like this:
let text1 = "something with foo and bar"
let...
Phenocryst asked 3/12, 2016 at 18:26
1
Solved
I have the following text file I would like to parse out to get the individual fields:
host_group_web = ( )
host_group_lbnorth = ( lba050 lbhou002 lblon003 )
The fields that I would like to extr...
Abirritant asked 5/11, 2016 at 6:0
1
Solved
If someone can please assist, I'm trying to do a sed append using regex and capture groups but its not working fully:
echo "#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/"...
Retrogression asked 23/8, 2016 at 14:19
2
Solved
When I use vim, I often use & to backreference the entire match within substitutions. For example, the following replaces all instances of "foo" with "foobar":
%s/foo/&bar/g
The benefit ...
Swoon asked 1/8, 2016 at 18:52
1
Solved
Intro
(you can skip to What if... if you get bored with intros)
This question is not directed to VBScript particularly (I just used it in this case): I want to find a solution for general regular...
Sacramental asked 13/5, 2015 at 14:50
1
Solved
Consider a string like this to extract the time information:
str = "Sun rises at 6:23 am & sets at 5:45 pm; Moon comes up by 7:20 pm and goes down by 3:45 am"
I wish to have an enumerator lik...
Idden asked 25/10, 2013 at 17:49
1
Solved
I am converting my boost-based regular expressions to C++11 regex. I have a capture group called url:
\s*?=\s*?(("(?<url>.*?)")|('?<url>.*?)'))
With boost, if you had an smatch you c...
Gumshoe asked 2/6, 2013 at 20:28
4
Solved
When I run this code:
print re.search(r'1', '1').groups()
I get a result of (). However, .group(0) gives me the match.
Shouldn't groups() give me something containing the match?
Pumpkin asked 5/9, 2011 at 19:24
3
Solved
I've got a regular expression that I'm trying to match against the following types of data, with each token separated by an unknown number of spaces.
Update: "Text" can be almost any character, wh...
Laaland asked 18/3, 2011 at 22:52
2
Solved
I need to identify (potentially nested) capture groups within regular expressions and create a tree. The particular target is Java-1.6 and I'd ideally like Java code. A simple example is:
"(a(b|c)...
Oneil asked 15/9, 2009 at 22:41
1
© 2022 - 2024 — McMap. All rights reserved.