A
Alf McLaughlin
Hello all!
I will be as brief as possible:
my $regexp = 'g[bx]|c[ak]|f[zm]'; #Let's say I have this regular
expression:
my $string = 'gbyyyyycayyyyyyfz'; #and I want to find out all the
occurences in the following string:
#so i do this:
while($string =~ /(?=($regexp))/ig) {
print "$1\n";
}
that prints out the following: "gb\nca\fz\n"
but, instead of printing these out I would like to print out the actual
part of the regular expression that matches (as efficiently as
possible!): "g[bx], c[ak], f[zm]"
i can imagine that the part of the regular expression that matches
might be efficiently captured much like the actual match is dumped into
$1.
Many thanks!
-Alf McLaughlin
I will be as brief as possible:
my $regexp = 'g[bx]|c[ak]|f[zm]'; #Let's say I have this regular
expression:
my $string = 'gbyyyyycayyyyyyfz'; #and I want to find out all the
occurences in the following string:
#so i do this:
while($string =~ /(?=($regexp))/ig) {
print "$1\n";
}
that prints out the following: "gb\nca\fz\n"
but, instead of printing these out I would like to print out the actual
part of the regular expression that matches (as efficiently as
possible!): "g[bx], c[ak], f[zm]"
i can imagine that the part of the regular expression that matches
might be efficiently captured much like the actual match is dumped into
$1.
Many thanks!
-Alf McLaughlin