On Sun, May 20, 2018 at 03:02:34PM -0700, ToddAndMargo wrote:
> On 05/20/2018 10:40 AM, Patrick R. Michaud wrote:
> > On Fri, May 18, 2018 at 03:28:20PM +0200, Timo Paulssen wrote:
> > > On 18/05/18 13:30, The Sidhekin wrote:
> > > > 
> > > >    /<!before .* gm> ^ <[d..z]>* $/
> > > 
> > > That's pretty good! Putting the beginning-of-string anchor ^ anywhere
> > > but the very start is surely an advanced move :)
> > 
> > FWIW, sometimes I think it's worth inverting the entire regex -- i.e., 
> > instead of matching finding things that do match, exclude the things that 
> > don't:
> > 
> >     / gm | <-[d..z]> /
> > 
> > This regex will match any string containing the sequence "gm" or any 
> > character that isn't in the range "d".."z", which is the inverse of what 
> > was required (strings containing only "d".."z" and never "gm").  Then use 
> > !~~ or some similar logic to get the strings wanted.
> > 
> > I recognize that this approach might not fit well in all cases, but it's 
> > another (perhaps cleaner) approach to getting what's wanted.
> 
> Something is wrong.  "h" is in the exclude list.
> 
> $ p6 'if "hgm" ~~ / gm | <-[d..z]> / {say "y"} else {say "n"}'
> y

The string "hgm" is in the "not include" list for the other regex as well 
(because it contains "gm"):

$ perl6 -e 'if "hgm" ~~ / <!before .* gm> ^ <[d..z]>* $/ { say "n" } else { say 
"y" }'
y


Pm

Reply via email to