my $exceptions = qr/_ALPHA|#ALPHA|XL5 ALPHA/; my $keepers = qr/ALPHA|BETA/; while (my $srch = <DATA>) { print "Matched ($srch)!\n" unless $srch=~/^(?:$exceptions|(?!$keeper +s).)*$/; } __DATA__ one with #ALPHA and good ALPHA one with just XL5 ALPHA one with just BETA one with _ALPHA and BETA
In reply to Re: Pattern matching when there are exception strings
by Roy Johnson
in thread Pattern matching when there are exception strings
by Moron
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |