in reply to qr/STRING/ fails with certain lookbehind expressions
The desired behavior can be forced by using //iaa
use v5.18.0; use warnings; my $pattern = "(?<!ss)abc"; my $regex = qr/$pattern/iaa; say 'ok' if 'ssqabc' =~ $regex; say 'ok' if 'ssabc' !~ $regex; say 'ok' if 'ssßabc' =~ $regex;
From perlre:
To forbid ASCII/non-ASCII matches (like "k" with "\N{KELVIN SIGN}"), specify the "a" twice, for example "/aai" or "/aia". (The first occurrence of "a" restricts the "\d", etc., and the second occurrence adds the "/i" restrictions.) But, note that code points outside the ASCII range will use Unicode rules for "/i" matching, so the modifier doesn't really restrict things to just ASCII; it just forbids the intermixing of ASCII and non-ASCII.
|
---|
In Section
Seekers of Perl Wisdom