Metacharacters
Within a regular expression, most characters represent
themselves. For example, the regular expression A
represents a capital A. There are, of
course, special characters that are processed differently:
.
By default, this matches any character except the newline character. In dot-all mode, this matches the newline character as well.
^
By default, this represents the beginning of the string literal. In multiline mode, this represents the beginning of a line within the string.
[XPath] Use of the caret to indicate that the beginning of a string or line is an addition to the regular expression syntax defined by XML Schema.
The caret can also be used inside a character class expression to indicate the negation of that character set. For example,
[a-f]
represents the lettersa
throughf
, while[^a-f]
represents every character except the lettersa
throughf
.$
[XPath] By default, this represents the end of the string literal. In multiline mode, this represents the end of a line within the string.
\
Escapes the following character.
|
The union operator. The expression
A|B
matches bothA
andB
. It does not matchAB
.?
Zero or one of a pattern. For example,
A[A-Z]?Z
matchesAZ
andABZ
, but notABCZ
.*
Zero or more of a pattern. For example,
A[A-Z]*
matches any string of uppercase basic Latin characters that starts with A and is followed by zero or more uppercase Latin characters. The stringsA
,ABC
,AA
, andAREALLYLONGSTRING
all match this expression.+
One or more of a pattern. For example, ...
Get XSLT, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.