![]() |
|
good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: Re: Re: This looks like someone sneezed and hit the keyboardby bunnyman (Hermit) |
on Feb 03, 2004 at 16:33 UTC ( [id://326228]=note: print w/replies, xml ) | Need Help?? |
No, everything in the regex must match, not just the first part of it, and the part in the middle with the (one|two|three) must match too. The thing that you must remember is that regexes can backtrack -- if they get to the end of the string without having matched yet, they can go back a few letters and try again. So the .* part will first try to match the entire string, because it is greedy. Then the middle part (one|two|three) must match, but there is nothing left in the string, and we must backtrack and try again. First we try going one letter back, then two, and eventually we either find the match or we backtrack all the way to the start and then there is no match.
In Section
Seekers of Perl Wisdom
|
|