in reply to qr/STRING/ fails with certain lookbehind expressions
My interpretation of the behaviour is that you're running afoul of ß (sz-ligature) matching SS when doing a case-insensitive match. This means that Perl will try to match s "inside" of ß, which then results in a variable-length look-behind pattern.
This theory easily explains the first behaviour, as Perl compiles
/(?<!ss)/i
to
/(?<!ß|ss)/i
This creates a variable-length lookbehind, which is what Perl does not like.
For your next examples, each "s" might start "inside" of an (expanded) ß:
ßtabc SSTABC STABC
I don't know why your third example compiles when the others do not, but I blame this on the inconsistency of ß matching ss. My suggestion would be to try to avoid /i and instead enumerate the alternatives if possible. That would mean to expand at least the critical words starting with s to character classes matching the upper- and lower-case variant:
/(?<!s)tart/i ; /(?<![Ss])[Tt][Aa][Rr][Tt]/ ;
Maybe you can fudge things by constructing your master regular expression from even more parts:
my $not_s= qr/(?<![Ss])/; # no explicit /i here, will never match insi +de ß my $rest= qr/abc/i; my $pattern= "$not_s$rest"; ...
I don't know why it doesn't happen for statically compiled regular expressions. Maybe this is the real bug here.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: qr/STRING/ fails with certain lookbehind expressions
by dave_the_m (Monsignor) on Jul 19, 2013 at 10:44 UTC | |
by hdb (Monsignor) on Jul 19, 2013 at 10:47 UTC | |
|
Re^2: qr/STRING/ fails with certain lookbehind expressions
by Anonymous Monk on Jul 22, 2013 at 14:54 UTC | |
by choroba (Cardinal) on Jul 22, 2013 at 15:04 UTC |