Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: qr/STRING/ fails with certain lookbehind expressions

by farang (Hermit)
on Jul 19, 2013 at 12:38 UTC ( #1045350=note: print w/ replies, xml ) Need Help??


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.


Comment on Re: qr/STRING/ fails with certain lookbehind expressions
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1045350]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (16)
As of 2014-10-01 15:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (29 votes), past polls