[xquery-talk] contains and tokenize
davidc at nag.co.uk
Mon Oct 23 17:10:29 PDT 2006
you could use matches instead of contains and add some word boundaries
to your regex. Schema/xpath regexp don't have built in word boundary
excpressions, but depending on your language rules something like
matches($text,concat('(^|[ ,\.;])',$keyword,($|[ ,\.;])'),'i')
for a case insensitive match against the keyword combined with either
the beginning or end of a string or a space , or ;.
If you want to use tokenize then you want = not contains, something like
upper-case($keyword) = tokenize(upper-case($text),'(\s|[\.,;])+'
which returns the sequence of words and then tests if any of them is
equal to the keyword.
(There are some differences, a case insenitive match for example isn't
the same thing as upper casing and then comparing, see
More information about the talk