Description
The functx:substring-before-last function returns the part of $arg that appears before the last occurrence of $delim. If $arg does not contain $delim, a zero-length string is returned.
Arguments and Return Type| Name | Type | Description |
$arg |
xs:string? |
the string to substring |
$delim |
xs:string |
the delimiter |
| return value |
xs:string |
XSLT Function Declaration| See XQuery definition. | | XSLT 2.0 Syntax: |
|---|
<xsl:function name="functx:substring-before-last" as="xs:string"
xmlns:functx="http://www.functx.com" >
<xsl:param name="arg" as="xs:string?"/>
<xsl:param name="delim" as="xs:string"/>
<xsl:sequence select="
if (matches($arg, functx:escape-for-regex($delim)))
then replace($arg,
concat('^(.*)', functx:escape-for-regex($delim),'.*'),
'$1')
else ''
"/>
</xsl:function>
|
Examples| XSLT Example | Results |
|---|
functx:substring-before-last(
'abc-def-ghi', '-')
|
abc-def
|
functx:substring-before-last('abcd-abcd', 'ab')
|
abcd-
|
functx:substring-before-last('abcd-abcd', 'x')
|
zero-length string |
Depends OnSee AlsoHistory |
|