Mercurial > hg > mpdl-group
diff software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/util/functx.xql @ 7:5589d865af7a
Erstellung XQL/XSL Applikation
author | Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 08 Feb 2011 15:16:46 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/util/functx.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,20 @@ +xquery version "1.0"; + +module namespace functx = "http://www.functx.com"; + +declare function functx:substring-before-last( $arg as xs:string?, $delim as xs:string ) as xs:string { + if (matches($arg, functx:escape-for-regex($delim))) + then replace($arg, + concat('^(.*)', functx:escape-for-regex($delim),'.*'), + '$1') + else '' +}; + +declare function functx:substring-after-last( $arg as xs:string?, $delim as xs:string ) as xs:string { + replace ($arg,concat('^.*',functx:escape-for-regex($delim)),'') +}; + +declare function functx:escape-for-regex( $arg as xs:string? ) as xs:string { + replace($arg, + '(\.|\[|\]|\\|\||\-|\^|\$|\?|\*|\+|\{|\}|\(|\))','\\$1') +}; \ No newline at end of file