Description
The functx:substring-before-match function returns the part of $arg that appears before the first match of $regex. If $arg does not match $regex, the entire $arg is returned. If $arg is the empty sequence, a zero-length string is returned.
Arguments and Return Type| Name | Type | Description |
$arg |
xs:string? |
the string to substring |
$regex |
xs:string |
the regular expression |
| return value |
xs:string |
XSLT Function Declaration| See XQuery definition. | | XSLT 2.0 Syntax: |
|---|
<xsl:function name="functx:substring-before-match" as="xs:string"
xmlns:functx="http://www.functx.com" >
<xsl:param name="arg" as="xs:string?"/>
<xsl:param name="regex" as="xs:string"/>
<xsl:sequence select="
tokenize($arg,$regex)[1]
"/>
</xsl:function>
|
Examples| XSLT Example | Results |
|---|
functx:substring-before-match(
'abc-def-ghi', '[dg]')
|
abc-
|
functx:substring-before-match(
'abcd-abcd', 'bc?')
|
a
|
functx:substring-before-match(
'abcd-abcd', 'x')
|
abcd-abcd
|
See AlsoHistory |
|