develooper Front page | perl.perl5.porters | Postings from October 2018

[perl #133630] unexpected 'variable length lookbehind' error in/h(?<!ssh)base/i

Thread Previous
From:
Tony Cook via RT
Date:
October 30, 2018 22:53
Subject:
[perl #133630] unexpected 'variable length lookbehind' error in/h(?<!ssh)base/i
Message ID:
rt-4.0.24-7225-1540939981-475.133630-15-0@perl.org
On Tue, 30 Oct 2018 14:12:05 -0700, jsailor@techhouse.org wrote:
> Running
> 
> perl -le 'print if /h(?<!ssh)base/i'
> 
> produces the error
> 
> Variable length lookbehind not implemented in regex m/h(?<!ssh)base/
> at -e line 1.
> 
> which is odd, because these work fine
> 
> perl -le 'print if /h(?<!xxh)base/i'
> perl -le 'print if /h(?<!xxh)baxe/i'
> 
> works fine.

I believe it's the "ss", which can match ß (\xdf, LATIN SMALL LETTER SHARP S), which makes it variable length.

Some ligatures can cause the same problem:

 $ perl -E 'qr/h(?<!ff)base/i'
 Variable length lookbehind not implemented in regex m/h(?<!ff)base/ at -e line 1.
 $ perl -E 'qr/h(?<!fi)base/i'
 Variable length lookbehind not implemented in regex m/h(?<!fi)base/ at -e line 1.

If you only need to match ASCII case-insensitively you can use the /aa flag:

 $ perl -E 'qr/h(?<!ssh)base/aai'

If you're perl is too old for the aa flag, I think you're stuck with using character classes and no /i flag.

Tony

---
via perlbug:  queue: perl5 status: new
https://rt.perl.org/Ticket/Display.html?id=133630

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About