So if I create a query in the BaseX 9.3.2 GUI, thus:
declare function local:processMatch($in as text(),$matchPattern as xs:string) as item()+ {  
  let $search as element() := analyze-string(normalize-space($in),$matchPattern)
  return $search
};
let $example := <para>These are a bunch of words, and some of the words are <em>special</em> words.</para>
for $text in $example//text()
          return local:processMatch($text,'bunch|special')
I get:
The trailing space after the are in the second fn:non-match element is gone.
Should that happen?  Can I make it stop happening by invoking the function differently?
Thanks!
Graydon