Matcher Class
Package: java.util.regex
The Matcher
class is used to match strings to a regex pattern represented by the Pattern class. For more information, see Pattern Class and Regular Expressions.
The Matcher
class does not have a constructor. Instead, you create an instance of the Matcher
class by first creating a Pattern
object, and then calling the Pattern
object’s matcher
method.
Methods
Method |
What It Does |
|
Returns the offset after the last character matched. |
|
Finds the next subsequence of the input sequence that matches the pattern. |
|
Resets this matcher and then attempts to find the next subsequence of the input sequence that matches the pattern, starting at the specified index. |
|
Returns |
|
Attempts to match the entire input sequence against the pattern. |
|
Returns the pattern that is interpreted by this matcher. |
|
Replaces every subsequence of the input sequence that matches the pattern with the given replacement string. |
|
Replaces the first subsequence of the input sequence that matches the pattern with the given replacement string. |
|
Returns |
Get Java For Dummies Quick Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.