in reply to Re: regex capturing problem
in thread regex capturing problem
is that matches are greedy (unless you tell them not to be) and will get the largest match they can
This is not strictly true with perls NFA based regex engine. They will match the leftmost longest match that they can. This doesnt mean the longest possible match as a DFA based regex engine (egrep) would provide. Thus
Will match "AAA" and not the entire string. But a DFA based regex engine would match the entire string."AAABBBBBBBBAAAAAAAAAAAA"=~m/A+|A+B+A+/;
OTOH reversing the option
Would match the entire string using either engine."AAABBBBBBBBAAAAAAAAAAAA"=~m/A+B+A+|A+/;
Yves / DeMerphq
---
Writing a good benchmark isn't as easy it might look.
|
|---|