Description
The functx:substring-before-last-match function returns the part of $arg that appears before the last match of $regex . If $arg does not match $regex , the entire $arg is returned. If $arg is the empty sequence, the empty sequence is returned.
Arguments and Return TypeName | Type | Description |
$arg |
xs:string? |
the string to substring |
$regex |
xs:string |
the regular expression |
return value |
xs:string? |
XQuery Function DeclarationSee XSLT definition. | declare namespace functx = "http://www.functx.com";
declare function functx:substring-before-last-match
( $arg as xs:string? ,
$regex as xs:string ) as xs:string? {
replace($arg,concat('^(.*)',$regex,'.*'),'$1')
} ; |
ExamplesXQuery Example | Results |
---|
functx:substring-before-last-match(
'abc-def-ghi', '[ce]') |
abc-d |
functx:substring-before-last-match(
'abcd-abcd', 'ab?') |
abcd- |
functx:substring-before-last-match(
'abcd-abcd', 'x') |
abcd-abcd |
See AlsoHistory |
Recommended Reading:
|