RE: Comment on xquery/xpath operators draft

> Problem #1:
> 
> 
> Ideally what I'd like is the absence of the second operator 
> (the dash in my
> case)  cause the entire string to be returned. This operator 
> could be called "substring-before-or-full" or somesuch.

I would think this can be achieved with regular expressions. Something like:

replace(., "(.*?)(-.*)?", "$1")

(untested)

> 
> Problem #2:
> 
> In the same application, I wanted to be able to strip off 
> just the final path segment of an arbitrary length URI.... What would work
is a "substring-after-last(op1, op2)" that returns the substring of op1
after the last op2 in the string.

Again, I think this is one for regular expressions. Something like: 

replace(., "(.*/)([^/]*)", "$2")

(again untested)


Michael Kay

Received on Thursday, 17 July 2003 13:03:02 UTC