I've looked at several Java regex tutorials, but haven't found a way to
do:
!regexString.equals(inputString);
using only regular expressions. I see that [^X] will return true for
any character that is not X, but what if I want the string that is not
"XYZ"? Entering [^XYZ] or [^(XYZ)] return true for any character that
is not X, Y, OR Z rather than any string that is not XYZ together. I
hope I've explained this clearly. Can anyone tell me how to use Java
regex for !String rather than !character?
Thanks
hiwa - 06 Sep 2006 02:22 GMT
danelaverty@gmail.com のメッセージ:
> I've looked at several Java regex tutorials, but haven't found a way to
> do:
[quoted text clipped - 9 lines]
>
> Thanks
Matching to the negative !X, if it was supported, couldn't have an
explicit and definitive boundary so regex engine could go wild.
Therefore, it is not supported from the beginning.
Jeffrey Schwab - 06 Sep 2006 14:25 GMT
> I've looked at several Java regex tutorials, but haven't found a way to
> do:
[quoted text clipped - 7 lines]
> hope I've explained this clearly. Can anyone tell me how to use Java
> regex for !String rather than !character?
You can check that you're not looking at a match to a given pattern via
(?!). This won't actually consume any characters, since the characters
didn't match.
(?!XYZ)
Does this cover it? If not, what specifically are you doing?
danelaverty@gmail.com - 07 Sep 2006 18:27 GMT
Thanks so much for your quick responses!