SeanLink11
SeanLink11

Reputation: 23

Is there a way to search with regex/symbols in XML searches

My data in xDB consist of values with / and regex. I tried using wildcards and other selection options but it doesn't seems to work, the only one that work is if I use the second one to search but it doesn't work with wildcards.

#1

    for $elem in /APP/TABLE/ROW where $elem/DATA contains text 'DL/B125.*' using wildcards
    return $elem

#2

    for $elem in /APP/TABLE/ROW where $elem/DATA='DL/B125KT'
    return $elem

Is there a way to search using wildcards where the values contains symbols/regex?

Upvotes: 0

Views: 35

Answers (1)

Michael Kay
Michael Kay

Reputation: 163458

Look for the matches() function -

for $elem in /APP/TABLE/ROW where matches($elem/DATA, 'DL/B125.*')
    return $elem

or more concisely

/APP/TABLE/ROW[matches(DATA, 'DL/B125.*')]

(Do remember that not every query has to be a FLWOR expression)

Upvotes: 2

Related Questions