#!/app/perl-5.8/bin/perl my $string = "ERROR blah license will expire"; print `/app/perl-5.8/bin/perl -version` . "\n\n"; if ( $string =~ /(ERROR.*?(?!(Error processing Cancel Execution|license will expire)))/ ){ print "MATCHED\n"; } else { print "NOT MATCHED\n"; } #### $ ./regex.pl This is perl, v5.8.3 built for sun4-solaris Copyright 1987-2003, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using `man perl' or `perldoc perl'. If you have access to the Internet, point your browser at http://www.perl.com/, the Perl Home Page. MATCHED