XML technologies / Regular expressions / Java / The Matcher object

(Excerpt from "Regular expressions" by Jeffrey E. F. Friedl)

Once the regex is associated with the subject string, you can apply the regex in various ways and examine the results. For a Matcher object m, calling m.find() applies the regex to the subject string and returns a Boolean indicating success. On success, calling m.group() returns the matched text.

Before exploring individual Matcher methods, here is an overview of the data managed by the matcher. Each item links to details. The first list contains data the programmer can change; the second contains read-only data.

Data the programmer can set and change:

The following matcher data can be queried but cannot be changed by a set method:

This condensed list is difficult to follow, but the items become clearer when methods are discussed by function in the following sections. The method table at the start of the chapter (see Alphabetical index of java.util.regex methods) helps navigation.

  

  

 

 

 

German edition copyright © 2008 by O’Reilly Verlag GmbH & Co. KG
You may print the online version for private use.
Otherwise, this chapter from "Reguläre Ausdrücke" is subject to the same terms as the bound edition: the work and all its parts are protected by copyright. All rights reserved, including reproduction, translation, microfilming, storage and processing in electronic systems.

O’Reilly Verlag GmbH & Co. KG, Balthasarstr. 81, 50670 Köln

back to top