develooper Front page | perl.beginners | Postings from November 2009

Re: Regular expressions question

Thread Previous
From:
mangled_us@yahoo.com
Date:
November 19, 2009 02:22
Subject:
Re: Regular expressions question
Message ID:
4c4b1723-5091-41f4-999e-d85a6a42ad1f@g27g2000yqn.googlegroups.com
> > > Can anyone tell me how to write a regular expression which matches
> > > anything _except_ a litteral string ?

> One could also use a zero-with negative look-ahead assertion:
>
> #!/usr/bin/perl -w
>
> use strict;
>
> while( my $line = <DATA> ){
>   if( $line =~ m/^(?!Nomatch)/ ){
>     print "match: $line";
>   }
>
> }

Thanks a lot for the reply,  that worked perfectly in my application.

David


Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About