Regular Expression Package for Java
The Regular Expresions that are supported by MailFaces are
modeled after the perl expressions.
It supports:
- char
- Match any character literally that doesn't have special
significance. Below are characters with special significance. You
can backslash special characters to have them treated as literals.
- .
- Match any character.
- [...]
- Match any in a class of characters, e.g., [a-z] matches all the
characters between 'a' and 'z' (inclusive).
- [^...]
- Match any NOT in a class of characters, e.g., [^a-z]
matches all characters NOT between 'a' and 'z' (inclusive).
- \s
- Matches a white space character (Space, Linefeed, Return, Tab).
- \S
- Matches a non-white space character.
- \w
- Matches word characters, e.g., same as [a-zA-Z0-9_]
- \W
- Matches non-word characters (opposite of \w)
- \d
- Matches digits 0-9.
- \D
- Matches everything except 0-9.
- \n, \r, \f, \t
- Matches NL, CR, FF, TAB respectively.
- $
- Matches at the end of a line.
- ^
- Matches at the beginning of a line.
- \b
- Matches if at a word boundery (consumes no characters).
- \B
- Matches if NOT at a word boundery.
- (
- Marks beginning of a group of matched characters.
- )
- Marks ending of a group of matched characters.
- |
- NEW!
Separates two alternative matches,
e.g., abc|def matches abc or def. Parentheses are used to specify
precedence, and "|" is by default the lowest precedence.
- \0, ..., \9
- Matches a previous (parenthisized) group of
matched characters.
- +
- Match one or more occurrences of previous RE
- *
- Match zero or more occurrences of previous RE
- ?
- Match zero or one occurrences of previous RE
NOTE: you have to put double back-slashes in your RE's when
you supply them in Java Strings. For example: "\\sWord\\s".