in reply to Pattern matching when there are exception strings
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
|
|---|