Revision 7.10
2/28/2012
XY
X
followed by
Y
X
|
Y
Either
X
or
Y
(
X
)
Back references
\
n
Whatever the
n
th
matched
Quotation
\
Nothing, but quotes the following character
\Q
Nothing, but quotes all characters until
\E
\E
Nothing, but ends quoting started by
\Q
Special constructs (noncapturing)
(?:
X
)
X
, as a noncapturing group
(?idmsux-idmsux)
Nothing, but turns match flags on off
(?idmsux-idmsux:
X
)
X
with the given flags on off
(?=
X
)
X
, via zerowidth positive lookahead
(?!
X
)
X
, via zerowidth negative lookahead
(?<=
X
)
X
, via zerowidth positive lookbehind
(?<!
X
)
X
, via zerowidth negative lookbehind
(?>
X
)
X
, as an independent, noncapturing group
Backslashes, escapes, and quoting
The backslash character (
'\'
) serves to introduce escaped constructs, as defined in the table
above, as well as to quote characters that otherwise would be interpreted as unescaped
constructs. Thus the expression
\\
matches a single backslash and
\{
matches a left brace.
It is an error to use a backslash prior to any alphabetic character that does not denote an escaped
construct; these are reserved for future extensions to the regularexpression language. A
backslash may be used prior to a nonalphabetic character regardless of whether that character is
part of an unescaped construct.
Backslashes within string literals in Java source code are interpreted as required by the
as either
or other
. It is therefore
necessary to double backslashes in string literals that represent regular expressions to protect
Page 214 of 228