develooper Front page | perl.perl5.porters | Postings from March 2019

[perl #132367] Allow variable length lookbehind for folded

Thread Previous
From:
Chris Wagner via RT
Date:
March 18, 2019 18:59
Subject:
[perl #132367] Allow variable length lookbehind for folded
Message ID:
rt-4.0.24-25010-1552935585-1470.132367-15-0@perl.org
On Tue, 30 Oct 2018 15:53:01 -0700, tonyc wrote:
> 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


I think that a simple fix to this problem would be to require that the single unicode character be used to trigger variable length case folding.  That way the appearance of a lower case ASCII sequence is always only interpreted as those ASCII characters.

e.g.
qr/(?<boss)man/i can only be qr/(?<[Bb][Oo][Ss][Ss])[Mm][Aa][Nn]/i 

To get variable length case folding you must write e.g.
qr/(?<boß)man/i will be qr/(?<[Bb][Oo](?-i:ß|s[s]))[Mm][Aa][Nn]/i 

Putting use re "/aa"; is another option.

Thanks








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

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