in reply to ensure ALL patterns in string

From the standpoint of clarity and maintainability, I'm not sure what you have now | in the OP isn't really best. But if you want an "all in one regex" solution, try something like:

c:\@Work\Perl\monks>perl -wMstrict -le "my $s = 'aZaXaYa'; ;; print 'all there' if $s =~ m{ \A (?= .*? X) (?= .*? Y) (?= .*? Z) }xm +s; " all there
See Look-Around Assertions in perlre; the Looking ahead and looking behind section in perlretut.

... so that I can just add remove space separated patterns ...

I don't understand what this means.


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^2: ensure ALL patterns in string
by previous (Sexton) on Jan 22, 2016 at 21:44 UTC
    re clarity I probably agree re not understanding... I mean the x y and z on the right in Dave's solution print "all\n" if 3 == grep {$var =~ m/$_/} qw(x y z); ie if you want another word you just pop it in after z...without typing anything else. Thank's for your help