The toString() method of Matcher Class is used to get the String representation of this matcher. This method is derived from the Object Class and behaves in the similar way.
public String toString()
Parameters: This method takes no parameters.
Return Value: This method returns a String value which is the String representation of this matcher.
Below examples illustrate the Matcher.toString() method:
java.util.regex.Matcher[pattern=(Geeks) region=0,25 lastmatch=]
java.util.regex.Matcher[pattern=(GFG) region=0,15 lastmatch=]
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.