Mega Code Archive

 
Categories / Java Book / 003 Essential Classes
 

0216 Pattern

The Pattern class defines no constructors. A pattern is created by calling the compile( ) factory method. One of its forms is shown here: static Pattern compile(String pattern) pattern parameter is the regular expression. Matcher is created by calling the matcher( ) factory method defined by Pattern. It is shown here: Matcher matcher(CharSequence str) str is the character sequence that the pattern will be matched against. CharSequence is an interface that defines a read-only set of characters. It is implemented by the String class. You can pass a string to matcher( ).