When you write a backtracking regex engine like the one in Perl 5, a full (variable length) look-ahead is pretty easy to implement.
It seems to me that the easy solution would produce bad performance. The easy solution requires matching each lookbehind subpattern at pos $current_pos - $max_match_length, which is 0 if /.*/ is used!
'bbbbbb' =~ /(?<=[^z]*a)b/
requires checking for "z" and "a" a total of 72 times each before failing even though the string is only 6 chars long!
Oops, I guess you covered this at the end, but it seems to me that it's a foremost concern.
It also forces
to produce'xiyjykz' =~ /(?<=x(.*)y(.*))z/s
but one might expect$1 = 'iyj'; $2 = 'k'
$1 = 'i'; $2 = 'jyk'
In reply to Re^2: Why is variable length lookahead implemented while lookbehind is not?
by ikegami
in thread Why is variable length lookahead implemented while lookbehind is not?
by Kc12349
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |