go to previous page   go to home page   go to next page

Answer:

No.


Whole Strings must Match

For the matches() method, the string must completely match the regular expression.

For some other Java methods, a regular expression is used to search a long text for a substring that matches. However, String.matches() requires the entire string to match.


QUESTION 6:

Say that you have a program that interacts with the user. The user is expected to end the program by entering "Q" or "Quit" or "q" or "quit".

Does this sound like a place to use a regular expression?