It works well and is reasonably quick.
Unfortunately $contains() is case sensitive and not useful for "words only" searches so I would prefer to use a regex along the lines of:
$out:= $notes.**[label ~> /($searchFor)/i] ;
but that, of course, just searches for "($searchFor)".
My question is: Can you construct, in a change node, a regex including a variable rather than a string literal?
(My guess is no; I've not found an example of such.)
@E1cid Mmm, yes, thank you. I did try that earlier today and the obnoxious error does disappear but it seems that \\w is passed to regex as \\w not \w - at least I think that's what happens as it didn't match correctly. I shall play again tomorrow.