Java Matcher Class
by, 04-26-2012 at 06:54 PM (501 Views)
Matcher class instances match the character sequences, against string pattern. Matchers are provided with input by CharSequence so that to provide support to matching, against characters from input sources.
Pattern helps to create the matcher when pattern’s matcher method is invoked. Once it has been made, different match operations could be performed by matcher.
- Whole input sequence is matched by the matcher method against the pattern.
- Input sequence is matched by the lookingAt method against the pattern.
- Input sequence is scaned by the final method, which is looked for the proceding sequence which will be matching the pattern,
A Boolean is returned by these methods which indicate the failure or success. Details regading successful match may be obtained when the state of matcher is being queried.
Methods are also defined by this class to replace the matched sequences, by new string. Content of them could be computed by the help of match result.