Re: regular expression to exclude a phrase
- From: rvtol+news@xxxxxxxxxxxx (Dr.Ruud)
- Date: Mon, 21 Jul 2008 11:27:04 +0200
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."
.
- Follow-Ups:
- Re: regular expression to exclude a phrase
- From: Rob Coops
- Re: regular expression to exclude a phrase
- References:
- regular expression to exclude a phrase
- From: Zhihuali
- regular expression to exclude a phrase
- Prev by Date: RE: Perl DBI->Connect: how to detect a a lost connection
- Next by Date: Re: regular expression to exclude a phrase
- Previous by thread: Re: regular expression to exclude a phrase
- Next by thread: Re: regular expression to exclude a phrase
- Index(es):
Relevant Pages
|