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