xpath - X-Path + RegEx matching pattern -
given following,
<line> <supplier>fuel surcharge - 36</supplier> <supplier>fuel surcharge - 35</supplier> <supplier>46081 46150 46250 46280 46286</supplier> <supplier>fuel surcharge - 35451</supplier> <supplier>46081</supplier> </line>
the idea here return "true" when node carries number of 5 digits iteration.
this have done far,
matches(./supplier, "[^(\d{5}\s*)+]");
the regex here extract value has 5 digits or without space regardless of iteration.
the results getting true. means not right somewhere. can assist me this.
thanks.
there 2 problems expression:
- no semicolon in end of xpath expression (syntax error).
- your regex messed up, matches not contain out of character class parentheses, digits, curly brackets, digit 5, spaces, , star , plus character.
fn:matches(xs:string?, xs:string)
requires 2 strings parameters, you're passing sequence of strings first one.
to call function for each node in axis step, add 1 (xpath 2.0 , above only). can use dot .
(context) in arguments.
try like
./supplier/matches(., "^(\d{5}\s*)+$")
which yield true third , fifth row. if must contain (and not constructed from) repeating pattern of fife-digit-numbers , spaces, remove ^
, $
regular expression.
Comments
Post a Comment