Modules | Version: 1 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
An implementation of this extension function in the EXSLT regexp namespace must conform to the behaviour described in this document. Implementations
Built-in support for
The following implementations of
Use CasesUse Case Package: regexp.match.use-cases.zip
The following use cases illustrate the functionality of
Change HistorySubmitted: 2001-06-24
|
http://www.exslt.org/regexp/functions/match/regexp.match.html last modified 2002-11-12