Modules | Implementer Page: regexp.match.html Function Syntaxobject regexp:match(string, string, string?)
The The second argument is a regular expression that follows the Javascript regular expression syntax. The third argument is a string consisting of character flags to be used by the match. If a character is present then that flag is true. The flags are:
The The following example illustrates a non-global match:
<xsl:for-each select="regExp:match('http://www.bayes.co.uk/xml/index.xml?/xml/utils/rechecker.xml',
'(\w+):\/\/([^/:]+)(:\d*)?([^# ]*)')">
Part <xsl:value-of select="position()" /> = <xsl:value-of select="." />
</xsl:for-each>
Gives the following result:
Part 1 = http://www.bayes.co.uk/xml/index.xml?/xml/utils/rechecker.xml
Part 2 = http
Part 3 = www.bayes.co.uk
Part 4 =
Part 5 = /xml/index.xml?/xml/utils/rechecker.xml
The following example illustrates a global match:
<xsl:for-each select="regExp:match('This is a test string', '(\w+)', 'g'">
Part <xsl:value-of select="position()" /> = <xsl:value-of select="." />
</xsl:for-each>
Gives the following result:
Part 1 = This
Part 2 = is
Part 3 = a
Part 4 = test
Part 5 = string
The following example illustrates another global match:
<xsl:for-each select="regExp:match('This is a test string', '([a-z])+ ', 'g')">
Part <xsl:value-of select="position()" /> = <xsl:value-of select="." />
</xsl:for-each>
Gives the following result:
Part 1 = his
Part 2 = is
Part 3 = a
Part 4 = test
The following example illustrates a global, case-insensitive match:
<xsl:for-each select="regExp:match('This is a test string', '([a-z])+ ', 'gi')">
Part <xsl:value-of select="position()" /> = <xsl:value-of select="." />
</xsl:for-each>
Gives the following result:
Part 1 = This
Part 2 = is
Part 3 = a
Part 4 = test
Implementations
The following XSLT processors support
Implementations of
ExamplesFunctionThe following example shows how to use the Source<?xml-stylesheet type="text/xsl" href="regexp.match.1.xsl" ?> <a> <c>Is this EXSLT? No. no</c> </a> Stylesheet<xsl:import href="regexp.match.msxsl.xsl" />
<xsl:template match="c">
<out>
<xsl:value-of select="." />
-
<xsl:for-each select="regexp:match(., 'no', 'gi')">
<xsl:value-of select="." />
</xsl:for-each>
</out>
</xsl:template>Result<out>Is this EXSLT? No. no -
Nono</out> |
http://www.exslt.org/regexp/functions/match/index.html last modified 2002-11-12