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

Answer:

Yesspacesmightbeuseful.


Pattern.COMMENTS

Pattern.COMMENTS mode lets you put whitespace in a regular expression. The whitespace will be ignored. For example,

Pattern pattern = 
    Pattern.compile( " ant | bat | cat | dog ", 
    Pattern.CASE_INSENSITIVE | Pattern.COMMENTS );   

matches "ant" or "bat" or "cat" or "dog" (any mix of upper and lower case). It will not match the strings " ant " or " ant" or similar. The spaces in the regular expression make it easier to read, but are not really part of it.

Use this feature with caution.


QUESTION 8:

Create a Pattern that matches q, Q, Quit, quit, QuiT, ...

Pattern quitPattern = 
  Pattern.compile(  |   ) ;