in reply to Re: Tidying and simplifying a regular expression
in thread Tidying and simplifying a regular expression
> ( examples with appended quantifiers )
Not really.
perlre is actually quite explicit about the why
> > > The caret tells Perl that this cluster doesn't inherit the flags of any surrounding pattern, but uses the system defaults (d-imnsx ), modified by any flags specified.
In other words: It's about preserving the flags of the embedded regex and assuming default if none are specified.
DB<7> $U=qr/U/ # always upper case DB<8> $i=qr/i${U}i/i # surrounding case insensitive DB<9> p $i (?^ui:i(?^u:U)i) DB<10> p 'iui' =~ $i DB<11> p 'iUi' =~ $i 1 DB<12> p 'IUI' =~ $i 1 DB<13> p 'IuI' =~ $i DB<14> p join "\n", grep { $_ =~ $i } <{i,I}{u,U}{i,I}> iUi iUI IUi IUI
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Wikisyntax for the Monastery
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Tidying and simplifying a regular expression
by AnomalousMonk (Archbishop) on Dec 10, 2017 at 05:02 UTC | |
by LanX (Saint) on Dec 10, 2017 at 22:22 UTC |