dragonchild has asked for the wisdom of the Perl Monks concerning the following question:
I've want to capture every pair of letters in a string, but I can't seem to get it to work.
I want it to print out "bl la ah", but, to capture the second level, I need to put another set of capturing parentheses within the lookahead. But, this puts the second character in $2, not $1 like I want to.$_ = "blah"; my @matches = /(.(?=.))/g; print "@matches\n";
Help!
------
We are the carpenters and bricklayers of the Information Age.
Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Capturing with look-ahead
by japhy (Canon) on Mar 04, 2002 at 15:14 UTC | |
Grabbing Adjacent Chars In A String - Re: Capturing with look-ahead
by metadoktor (Hermit) on Mar 04, 2002 at 15:57 UTC | |
Re: Capturing with look-ahead
by danger (Priest) on Mar 04, 2002 at 17:27 UTC | |
by japhy (Canon) on Mar 04, 2002 at 21:02 UTC | |
by Ido (Hermit) on Mar 04, 2002 at 21:24 UTC | |
by japhy (Canon) on Mar 04, 2002 at 21:53 UTC | |
by Ido (Hermit) on Mar 05, 2002 at 00:44 UTC | |
Re: Capturing with look-ahead
by Ido (Hermit) on Mar 04, 2002 at 19:31 UTC | |
by dragonchild (Archbishop) on Mar 04, 2002 at 19:34 UTC | |
by mdillon (Priest) on Mar 04, 2002 at 22:50 UTC |
Back to
Seekers of Perl Wisdom