[xquery-talk] string manipulation
jmdyck at ibiblio.org
Sun Feb 5 14:42:30 PST 2006
John Snelson wrote:
> Instead of that, you could also try:
> replace("book/title/author", "/.*?$", "")
I think that won't work. Instead, two overlapping substrings
('/title/author' and '/author') both match the pattern, and the
replace() function is obliged to replace the first (leftmost) one,
resulting in just "book".
That is, the reluctance of a subpattern (like '.*?') only exerts
influence over a particular choice-point within a given partial match.
It never eliminates a match that could have occurred in the absence of
In F&O 18.104.22.168, note the example
replace("abracadabra", "a.*?a", "*") returns "*c*bra"
The shortest possible match for the pattern is "aca", but that match is
not one of the ones selected for replacement, because it overlaps with
the first "abra" match, and the latter is leftmost.
More information about the talk