Name
[2.0] <xsl:analyze-string>
Allows you to compare a string and a regular expression.
Changes in XSLT 2.0
<xsl:analyze-string> is
new to XSLT 2.0.
Category
Instruction.
Required Attributes
selectAn XPath expression that defines the string to be analyzed. The expression is converted to a string if necessary.
regexThe regular expression. Regular expressions commonly use curly braces (
{and}), which XSLT interprets as the start and end of an attribute value template. For this reason, any curly braces in a regular expression must be doubled. For example, the regular expression"[0-9]{{5}}"matches a five-digit number, while"[0-9]{5}"matches a one-digit number followed by the number5.Note
It is a fatal error if the regular expression matches a zero-length string. See Appendix E for more details.
Optional Attribute
flagsThe
flagsattribute modifies how the regular expression is processed. There are four different flags:sRegular expressions are evaluated in what the specs refer to as “dot-all” mode. When this flag is used, the dot operator (
.) matches any character. Under normal processing (without thesflag), the dot operator matches any character except the newline character (#xA). This flag is useful when you want to match strings that might include a newline character.mRegular expressions are evaulated in multiline mode. By default, the meta-character (
^) matches the start of the entire string, while $ matches the end of the entire string. In multiline mode, ^ matches the start of any ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access