|negating words with Java regular expressions Raj.Ashar@jhuapl.edu (2004-07-13)|
|Re: negating words with Java regular expressions firstname.lastname@example.org (=?iso-8859-1?q?Amit=20Shanbhag?=) (2004-07-13)|
|Date:||13 Jul 2004 22:33:14 -0400|
|Posted-Date:||13 Jul 2004 22:33:14 EDT|
In regular expressions
If you are looking for ";" not preceeded by a number
you could do it with the zero-width negative look
For your particular case, this would be.
This will look for numerical characters preceeding a
";", -->this is called look behind
the search will be negated "(?! )" ---> hence negative
The matching string will always only return ";" or
nothing at all. ie the pattern "[0-5]*" will never
contribute any chanracter to the resultant match-->
For more info look at
--- Raj Ashar <Raj.Ashar@jhuapl.edu> wrote: > All, is
there a way to negate words using regular
> expressions as
> implemented by Java? I know that one can negate the
> characters in a
> character class using the caret ([^a-z]), but I
> would like to build
> expressions of the form:
> Match ";" and not "5;".
> Though one can match strings positively (as in match
> against string
> "abc"), there does not appear to be a simple way to
> indicate negative
> matches (do not match "abcd").
Return to the
Search the comp.compilers archives again.