Java Reference
In-Depth Information
Table 9-1 provides an expanded list of metacharacters available for Java regexs.
Table 9-1. Regex metacharacters
Optional character—zero or one instance
Zero or more of preceding character
One or more of preceding character
Between M and N instances of preceding character
A digit
A nondigit character
A word character
Digits, letters, and _
A nonword character
A whitespace character
A nonwhitespace character
Newline character
Tab character
Any single character
Does not include newline in Java
Any character contained with the brackets
Called a character class
[ ]
Any character not contained with the brackets
Called a negated character class
[^ ]
Build up a group of pattern elements
Called a group (or capturing group)
( )
| Deine alternative possbilities
Implements logical OR
Start of string
End of string
There are a few more, but this is the basic list, and from this, we can construct more
complex expressions for matching such as the examples given earlier in this section:
Search WWH ::

Custom Search