77.7k views
1 vote
Which of the following statements is true?

a. Class Matcher provides methods find, lookingAt, replaceFirst and replaceAll.
b. Method matches (from class String, Pattern or Matcher) will return true only if the entire search object matches the regular expression.
c. Methods find and lookingAt (from class Matcher) will return true if a portion of the search object matches the regular expression.
d. All of the above.

User Fedeisas
by
7.8k points

1 Answer

3 votes

Final answer:

Option (D), All statements regarding the Java regex classes and methods in the question are true. Class Matcher has a variety of methods for pattern matching and manipulation, the method matches requires a full match, and methods find and lookingAt can match subsequences.

Step-by-step explanation:

The question is asking which statement about Java regex classes and methods is true. The correct answer is d. All of the above. Let's break down each statement:

  • a. The class Matcher does indeed provide methods such as find, lookingAt, replaceFirst, and replaceAll.
  • b. The method matches (from class String, Pattern, or Matcher) returns true only if the entire region sequences match the given regular expression.
  • c. The methods find and lookingAt from class Matcher return true if any subsequence of the input sequence matches the pattern, with find searching for a subsequence anywhere in the input, while lookingAt matches only from the beginning of the input.

All of these statements are correct, making the answer to the question 'All of the above'.

User Mouse On Mars
by
8.3k points