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 / January 2007

Tip: Looking for answers? Try searching our database.

Retrieving the matches to a regular expression

Thread view: 
Siam - 03 Jan 2007 00:38 GMT
Hi all,

Is there any way of not only checking a regular expression matches a
string, but also grabbing the the values that the wildcards matched to?

e.g, we know "Coordinate 234 124 12" matches with "Coordinate \\d++
\\d++ \\d++", but how could we actually get the values 234, 124 and 12
that matched the numbers in the pattern? I would've thought this would
by quite commonly done, but all I could find in the APIs were simple
boolean tests. I want to avoid simply scanning my way through the
string manually, cos I'm sure this was already done when doing the
matching.

Any ideas?

Cheers,

Siam
Eric Sosman - 03 Jan 2007 02:39 GMT
> Hi all,
>
[quoted text clipped - 8 lines]
> string manually, cos I'm sure this was already done when doing the
> matching.

    Go back to the documentation for java.util.regex.Pattern
and look for the section entitled "Groups and Capturing."

Signature

Eric Sosman
esosman@acm-dot-org.invalid



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.