Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2006

Tip: Looking for answers? Try searching our database.

Java Regex: How to "NOT" a group?

Thread view: 
danelaverty@gmail.com - 06 Sep 2006 01:31 GMT
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!


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.