The documentation for Matcher.lookingAt clearly explains that the lookingAt area lookingAt trying to match:
Like the matches method, this method always starts at the beginning of the scope; unlike this method, it does not require coordination of the entire area.
So no, lookingAt does not require matching the entire string. Then what is the difference between lookingAt and find ? From the Matcher Javadoc Review :
- The
matches method tries to match the entire input sequence with a pattern. - The
lookingAt method tries to match an input sequence, starting from the beginning, with a pattern. - The
find method scans the input sequence, looking for the next subsequence that matches the pattern.
lookingAt always starts from the beginning, but find will scan the original position.
On the other hand, matches has a fixed start and end, lookingAt has a fixed start, but a variable end, and find has a variable start and end.
source share