Think about Loose Coupling | |
PerlMonks |
Re: Lookahead assertionby Athanasius (Archbishop) |
on Oct 17, 2013 at 03:48 UTC ( [id://1058592]=note: print w/replies, xml ) | Need Help?? |
Look-ahead is (?= ), not (?: ) !
Update: The use of (?: ) instead of (?= ) appears to be a misprint in the Camel Book. The following explanation from that same section (page 248) is worth noting (at least, it helped me to understand what is going on): When the engine sees that it should try again because of the /g, it steps one character past where last it tried. This explains why the final . in BrowserUk’s solution is not strictly necessary. But BrowserUk’s regex can be usefully generalised to step forward an arbitrary number of characters. For example, to capture 3 digits and then step forward 2 characters:
Hope that helps,
In Section
Seekers of Perl Wisdom
|
|