Created
November 28, 2011 22:42
-
-
Save mitchty/1402423 to your computer and use it in GitHub Desktop.
Confused on positive lookahead in this case
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my $var = "anchor1 lkajfdlkj | |
match | |
till | |
the | |
next | |
anchor2 | |
more | |
stuff | |
anchor3 | |
blah | |
till | |
eof/eol | |
"; | |
$var =~ /anchor1.*(?=anchor2)/ms; | |
print $& . "\n"; | |
print "---\n"; | |
$var =~ /anchor1.*(?=anchor)/ms; | |
print $& . "\n"; | |
# I'm curious why the first match of "anchor" isn't matching anchor2 in the look-ahead. I have to be missing something obvious. | |
# anchor1 lkajfdlkj | |
# match | |
# till | |
# the | |
# next | |
# | |
# --- | |
# anchor1 lkajfdlkj | |
# match | |
# till | |
# the | |
# next | |
# anchor2 | |
# more | |
# stuff |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment