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 |
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.
Read now
Unlock full access