I faced a problem with functx module dealing with strings with end of line characters. The following code should work (?)
declare %unit:test function test:substring-before-last() {
let $title := 'Something
blah other'
let $expected-title := 'Something
blah'
return unit:assert-equals(functx:substring-before-last($title, ' other'),
$expected-title)
};
However it gives a failure
"Something
blah" expected, "Something
blah other" returned.
Removing line breaking makes the test working. What I don't understand? :)
BR

I think the issue is in the definition or implementation of the functx function http://www.xqueryfunctions.com/xq/functx_substring-before-last.html:
and the regular expression dot
.matching and thereplacedefault "If the input string contains no substring that matches the regular expression, the result of the function is a single string identical to the input string."; if you add the flagsmargumentyou get the right match and replacement and comparison.