Re: regular expression to exclude a phrase



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."

.



Relevant Pages

  • regular expression to exclude a phrase
    ... I was wondering if there's a way to specify "not including this phrase" in perl regexp. ... Like such two strings: ... However now I want to say "not including the phrase 'ab'", then the string 2 should be matched. ...
    (perl.beginners)
  • Re: regular expression to exclude a phrase
    ... I was wondering if there's a way to specify "not including this phrase" in perl regexp. ... will match both of those strings. ...
    (perl.beginners)
  • Re: regular expression to exclude a phrase
    ... #make the world go round ... phrase" in perl regexp. ... Like such two strings: ... including the phrase 'ab'", then the string 2 should be matched. ...
    (perl.beginners)
  • Re: reverse of concatenate
    ... >I am in search for the option which is opposite to concatenate. ... This will also remove punctuation. ... The formula will return empty strings once it gets past the end of the phrase. ...
    (microsoft.public.excel.misc)
  • Re: Truncated Output
    ... It looks to me the "DISTINCT" Keyword is the problem since JET will have to ... compare Strings to decide wthether 2 Strings are the same or not. ... say by turning the output in "Phrase" into a memo ...
    (microsoft.public.access.queries)