in reply to Regular expression quantifiers and the /gsmx modifiers
Consider:
Here only the second regex matches because in the first after the $ matches there is still a newline left and therefore the ^ does not match. You need to consume that in the regex as the second example shows.use strict; my $s = <<"__end__"; hubba bubba __end__ print "matched 1\n" if $s =~ m/^hubba$ ^bubba$/smx; print "matched 2\n" if $s =~ m/^hubba$ \n ^bubba$/smx;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Regular expression quantifiers and the /gsmx modifiers
by davis (Vicar) on Jun 16, 2012 at 22:17 UTC |