Javatpoint Logo
Javatpoint Logo

Java Pattern toString() Method

The toString() Method of Pattern class returns the String representation of compiled pattern. This method of Pattern class overrides the "toString" in class Object.

Syntax:

Parameter

NA

Returns

This method returns the string representation of this pattern.

Example 1

Test it Now

Output:

[a-zA-Z]+\.? Pattern to be matched
[a-zA-Z]+\.? Pattern to be matched

Example 2

Test it Now

Output:

(.*)(\d+)?# 2 groups
java.util.regex.Matcher[pattern=(.*)(\d+)?# 2 groups region=0,52 lastmatch=]
Next TopicJava Pattern





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA