Skip to Content
Java in a Nutshell, 5th Edition
book

Java in a Nutshell, 5th Edition

by David Flanagan
March 2005
Intermediate to advanced
1254 pages
104h 21m
English
O'Reilly Media, Inc.
Content preview from Java in a Nutshell, 5th Edition

Name

MatchResult

Synopsis

This interface represents the results of a regular expression matching operation performed by a Matcher. Matcher implements this interface directly, and you can use the methods defined here to obtain the results of the most recent match performed by a Matcher. You can also save those most recent match results in a separate immutable MatchResult object by calling the toMatchResult( ) method of the Matcher.

The no-argument versions of the start( ) and end( ) method return the index of the first character that matched the pattern and the index of the last character that matched plus one (the index of the first character following the matched text), respectively. Some regular expressions can match the empty string. If this occurs, end( ) returns the same value as start( ). The no-argument version of group( ) returns the text that matched the pattern.

If the matched Pattern includes capturing subexpressions within parentheses, the other methods of this interface provide details about the text that matched each of those subexpressions. Pass a group number to start( ), end( ), or group( ) to obtain the start, end, or text that matched the specified group. groupCount( ) returns the number of subexpressions. Groups are numbered from 1, however, so legal group numbers run from 1 to the value returned by groupCount( ). Groups are ordered from left-to-right within the regular expression. When there are nested groups, their ordering is based on the position of the opening ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java in a Nutshell, 8th Edition

Java in a Nutshell, 8th Edition

Benjamin J. Evans, Jason Clark, David Flanagan
Java in a Nutshell, 7th Edition

Java in a Nutshell, 7th Edition

Benjamin J. Evans, David Flanagan
Learning Java, 5th Edition

Learning Java, 5th Edition

Marc Loy, Patrick Niemeyer, Daniel Leuck
Learning Java, 4th Edition

Learning Java, 4th Edition

Patrick Niemeyer, Daniel Leuck

Publisher Resources

ISBN: 0596007736Supplemental ContentErrata Page