You could simply say this:
if ( ! m/ab/ ) {
 #make the world go round
}
Or assuming you are looping thru a list you could say something like:
foreach my $item ( @list ) {
 next if ( $item =~ m/ab/ );
 #make the world go round
}

I personaly like the second one better because of the readability but that
might just be me.

Regards,

Rob

ps, Sorry DR. Ruud I hit the wrong button and replied only to you... oops
:-(

On Mon, Jul 21, 2008 at 11:27 AM, Dr.Ruud
<[EMAIL PROTECTED]<[EMAIL PROTECTED]>>
wrote:

> zhihuali schreef:
>
> > I was wondering if there's a way to specify "not including this
> > phrase" in perl regexp.
> > Like such two strings:
> > axbcabcd
> > axbcacbd
> >
> > If I say "not including the letter a or the letter b" (=~/[^a^b]/)
> > then neither of them will be matched.
>
> The [^a^b] doesn't mean what you think it means. The "^" only has a
> special meaning at the start.
>
>
> > However now I want to say "not
> > including the phrase 'ab'", then the string 2 should be matched.
> > But I can't figure out how to specify the second condition by regexp.
> > Could anyone help me?
>
> There are many ways to do this, but let's play it simple:
>
>    if ( m/ab/ ) {
>        # do nothing
>    }
>    else {
>        # do something
>    }
>
> --
> Affijn, Ruud
>
> "Gewoon is een tijger."
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> http://learn.perl.org/
>
>
>

Reply via email to