DEV Community

MOMO
MOMO

Posted on

Answer: XQuery negate regex

Just use this pure XPath 2.0 expression (XPath 2.0 is a proper subset of XQuery):

("2a2", "32", "1234", "12", "32a3", "12345", "")
                      [not(matches(., "^[0-9]{4}$"))]

When this expression is evaluated (in XQuery, XSLT 2+ or any standalone XPath/XQuery interpreter tool), the wanted, correct result is produced:

2a2 32 12 32a3

Top comments (0)