Revision 7.10
2/28/2012
them from interpretation by the Java bytecode compiler. The string literal
"\b"
, for example,
matches a single backspace character when interpreted as a regular expression, while
"\\b"
matches a word boundary. The string literal
"\(hello\)"
is illegal and leads to a compiletime
error; in order to match the string
(hello)
the string literal
"\\(hello\\)"
must be used.
Character Classes
Character classes may appear within other character classes, and may be composed by the union
operator (implicit) and the intersection operator (
&&
). The union operator denotes a class that
contains every character that is in at least one of its operand classes. The intersection operator
denotes a class that contains every character that is in both of its operand classes.
The precedence of characterclass operators is as follows, from highest to lowest:
1
Literal
escape
\x
2
Grouping
[...]
3
Range
a-z
4
Union
[a-e][i-u]
5
Intersection
[a-z&&[aeiou]]
Note that a different set of metacharacters are in effect inside a character class than outside a
character class. For instance, the regular expression
.
loses its special meaning inside a character
class, while the expression
-
becomes a range forming metacharacter.
Line terminators
A
line terminator
is a one or twocharacter sequence that marks the end of a line of the input
character sequence. The following are recognized as line terminators:
A newline (line feed) character (
'\n'
),
A carriagereturn character followed immediately by a newline character (
"\r\n"
),
A standalone carriagereturn character (
'\r'
),
A nextline character (
'\u0085'
),
A lineseparator character (
'\u2028'
), or
A paragraphseparator character (
'\u2029
).
mode is activated, then the only line terminators recognized are newline
characters.
Page 215 of 228