in reply to positions of all regexp matches
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: •Re: positions of all regexp matches
by flounder99 (Friar) on Oct 14, 2003 at 18:58 UTC | |
by merlyn (Sage) on Oct 14, 2003 at 19:06 UTC | |
by flounder99 (Friar) on Oct 14, 2003 at 19:57 UTC | |
by merlyn (Sage) on Oct 14, 2003 at 20:04 UTC | |
by sandfly (Beadle) on Oct 14, 2003 at 22:40 UTC |