in reply to Re^3: Explain a regexp matched group result
in thread Explain a regexp matched group result
Thank you very much. So I cannot get individuals without removing the repetition and do a while ()... i.e.
Bad news for me, but again mega thanks for your very clear answer. ps:use strict; use warnings FATAL => 'all'; my $string = "aacbbbcac"; my $re1 = qr/((a+)?(b+)?(c))/; while ($string =~ /$re1/g) { foreach (0..$#-) { printf "Group %d: <%s>\n", $_, defined($-[$_]) ? substr($string, $ +-[$_], $+[$_] - $-[$_]) : ''; } print "\n"; }
Group 0: <aac> Group 1: <aac> Group 2: <aa> Group 3: <> Group 4: <c> Group 0: <bbbc> Group 1: <bbbc> Group 2: <> Group 3: <bbb> Group 4: <c> Group 0: <ac> Group 1: <ac> Group 2: <a> Group 3: <> Group 4: <c>
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^5: Explain a regexp matched group result
by ig (Vicar) on Oct 28, 2013 at 19:31 UTC | |
by jdd (Acolyte) on Oct 28, 2013 at 19:45 UTC | |
by ig (Vicar) on Oct 28, 2013 at 20:52 UTC |
In Section
Seekers of Perl Wisdom