Re: regular expression to exclude a phrase

2008-07-21 Thread Rob Dixon
Octavian Rasnita wrote: > > I wanted to test something like: > > Match only if the string contains somewhere a "ab" in it but it doesn't > contain "ab" between < and >. > > For example: > > "zzz <> ttt> ab" - matches > "z ab xx" - matches > "zzz ab <>ab> tt" - doesn't match > "ab " - doesn'

Re: regular expression to exclude a phrase

2008-07-21 Thread Rob Coops
So building something like this in 1 regex: "zzz <> ttt> ab" - matches "z ab xx" - matches "zzz ab <>ab> tt" - doesn't match "ab " - doesn't match That took me a while to work out but it can be done: #!/usr/local/bin/perl use strict; use warnings; my @data; $data[0] = "zzz <> ttt> ab"; $data[1

Re: regular expression to exclude a phrase

2008-07-21 Thread Octavian Rasnita
From: "Rob Coops" <[EMAIL PROTECTED]> > 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 also had this p

Re: regular expression to exclude a phrase

2008-07-21 Thread Rob Coops
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

Re: regular expression to exclude a phrase

2008-07-21 Thread Dr.Ruud
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

Re: regular expression to exclude a phrase

2008-07-19 Thread Rob Dixon
zhihuali wrote: > > 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. However now I want to say

regular expression to exclude a phrase

2008-07-19 Thread zhihuali
Hi netters, 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. However now I want to say "not including the ph