Note the care given to find overlapping matches.my $string = "hello world ballloon"; my $regex = qr/ll/; my @matches; push @matches, [$-[1], $+[1]] while $string =~ /(?=($regex))/g; print "@$_\n" for @matches;
-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.
In reply to •Re: positions of all regexp matches
by merlyn
in thread positions of all regexp matches
by glwtta
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |