functx:substring-before-match

The substring before the last text that matches a regex

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.

Parameters

Description

arg:string()

the string to substring

regex:string()

the regular expression

Examples

XPath

Results

functx:substring-before-match(‘abc-def-ghi’, ‘[dg]’)

abc-

functx:substring-before-match(‘abc-def-ghi’, ‘[dg]’)functx:substring-before-match(‘abcd-abcd’, ‘bc?’)

a

functx:substring-before-match(‘abcd-abcd’, ‘x’)

abcd-abcd

See Also