Javatpoint Logo
Javatpoint Logo

Java Matcher lookingAt() method

The lookingAt() method of Matcher class is used to match the input sequence against the beginning of the text. This method is similar to matches() except the difference that matches() match the regular expression against the whole text.

Syntax:

Parameter

No parameter

Returns

true if, and only if, a prefix of the input sequence matches this matcher's pattern

Example 1

Test it Now

Output:

lookingAt = true

Example 2

Test it Now

Output:

lookingAt = true
matches   = false

Example 3

Test it Now

Output:

  lookingAt = true
  java.util.regex.Matcher[pattern=java programm region=0,50 lastmatch=java programm]
Next TopicJava Matcher class




Help Others, Please Share

facebook twitter pinterest