Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: qr/STRING/ fails with certain lookbehind expressions

by farang (Chaplain)
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.

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 rifling through the Monastery: (9)
As of 2016-07-01 11:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (410 votes). Check out past polls.