I am trying to match stand alone numbers in some comma separated string , after splitting this string by commas and save it to variable $i
, I use this regular expression:
fn:matches(fn:normalize-space($i), "(?<!\S)\d (?!\S)")
- Example : (123) should return
true
. - Example: (abc123) sholud return
false
. - Example: (abc 123 abc) should return
false
.
But, it gives me:
[1.0-ml] XDMP-REGEX: (err:FORX0002) .
What is the wrong with this expression?
CodePudding user response:
Lookahead and lookbehind are not supported in XQuery regex expressions.
However, you don't need them if you are just looking to verify that the value is purely numeric values. You can anchor the expression to the beginning and end of the value and ensure that everything in-between is a number:
fn:matches(fn:normalize-space($i), "^\d $")