home contribute faq download

FunctX XQuery Functions

functx:substring-after-match

The substring after the first text that matches a regex

Google
Webxqueryfunctions.com

Description

The functx:substring-after-match function returns the part of $arg that appears after the first 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 Type

NameTypeDescription
$arg xs:string? the string to substring
$regex xs:string the regular expression
return value xs:string?

XQuery Function Declaration

See XSLT definition.
declare namespace functx = "http://www.functx.com";
declare function functx:substring-after-match
  ( $arg as xs:string? ,
    $regex as xs:string )  as xs:string? {

   replace($arg,concat('^.*?',$regex),'')
 } ;

Examples

XQuery ExampleResults
functx:substring-after-match(
  'abc-def-ghi', '[ce]')
-def-ghi
functx:substring-after-match(
  'abcd-abcd', 'ab?')
bcd-abcd
functx:substring-after-match(
  'abcd-abcd', 'x')
abcd-abcd

See Also

fn:substring-afterThe substring after the first occurrence of a delimiter
functx:substring-after-last-matchThe substring after the last text that matches a regex
functx:substring-before-matchThe substring before the last text that matches a regex

History

Published OnLast UpdatedContributor(s)
2007-08-112007-08-11Priscilla Walmsley, Datypic, pwalmsley@datypic.com, http://www.datypic.com
Datypic XQuery Services

Recommended Reading:

XQuery