Think about Loose Coupling | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Your regex doesn't force a non-greedy behaviour. I'll try to explain with a simplified text example:
The engine reads $text from left to right and will have a try with starting at the first "ABC", using the complete following string until end of line. As that's exactly what the regex requested, this result is returned. There's no condition which forces the engine to search for a shorter result. There will be no second run which checks, if the current result may contain a shorter result. The first valid match will be returned; this isn't always the best match. In reply to Re^2: Non-greedy regex behaves greedily
by linuxer
|
|