[xquery-talk] string manipulation

John Snelson jsnelson at sleepycat.com
Sun Feb 5 20:23:49 PST 2006


Florent Georges wrote:
> John Snelson wrote:
> 
>>replace("book/title/author", "/.*?$", "")
> 
>   Does this garantee to return "book/title" and not "book" ?  The
> longuest match would win, doesn't it ?  Personally, I'd use the regexp
> '/[^/]*$'.  BTW, why the '?' after the '*' ?

"*?" is a reluctant version of the "*" quantifier, meaning it matches 
the shortest sequence, rather than the longest. My regular expression 
works because of this - but yours will work as well.

John

-- 
John Snelson, Berkeley DB XML Engineer
Sleepycat Software, Inc
http://www.sleepycat.com

Contracted to Sleepycat through Parthenon Computing Ltd
http://blog.parthcomp.com/dbxml


More information about the talk mailing list