Read XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition Online
Authors: Michael Kay
Warning: The
regex
attribute is an attribute value template. This makes it possible to construct the regex at runtime, using an XPath expression. For example, the regex can be supplied as a stylesheet parameter. The downside of this is that curly braces within the attribute value must be doubled if they are to be treated as part of the regex, rather than having their special meaning for attribute value templates. For example, to match a sequence of three digits, write
regex=“[0-9]{{3}}”
.
The
flags
attribute controls how the regex is to be interpreted. Four flags are defined, each denoted by a single letter, and they can be written in any order. Like the
regex
attribute,
flags
may be written as an attribute value template. The meaning of the flags is defined in detail in Chapter 14 and is summarized below.
Flag | Meaning |
i | Selects case-insensitive mode. In simple terms, this means that X and x will match each other. |
m | Selects multiline mode. In this mode, the metacharacters ∧ and $ match the beginning and end of each line; otherwise, they match the beginning and end of the entire string. |
s | Selects dot-all mode. In this mode the metacharacter . matches any character, whereas normally it matches any character except a newline (x0A). |
x | Allows whitespace to be used as an insignificant separator within the regex. |
Content
Either an
An XSLT 2.0 processor will ignore any
The elements
Effect
The XPath expression given in the
select
attribute is evaluated and provides the input string to be matched by the regex. A type error occurs if the value of this expression can't be converted to a string using the standard conversion rules described on page 505.