|
[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message] using a variable within a regexp pattern in XQueryMichael Kay mike at saxonica.comFri Oct 2 00:39:10 PDT 2009
It's very unhelpful to report that something "doesn't work" without saying
how it failed. And if you expected the expression to do something useful,
it's useful to say what you expected it to do: you can't expect us to guess
the intention behind incorrect code.
If $q is a variable containing part of a regular expression, then you can
include it in a regex using the concat function:
matches(., concat('(', $q, ')*')
Regards,
Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay
_____
From: http://x-query.com/mailman/listinfo/talk [mailto:http://x-query.com/mailman/listinfo/talk] On Behalf
Of Manuel Souto Pico
Sent: 01 October 2009 19:53
To: http://x-query.com/mailman/listinfo/talk
Subject: using a variable within a regexp pattern in XQuery
Hi,
I'm a bit stuck trying to run a regexp pattern in a XQuery search file.
(1) where $record/langSet[@xml:lang="en"]/tig/term[matches(., $q)]
works
(2) where $record/langSet[@xml:lang="en"]/tig/term[matches(., "$q")]
doesn't work
(3) where $record/langSet[@xml:lang="en"]/tig/term[matches(., "^$q.*$")]
doesn't work
(4) where $record/langSet[@xml:lang="en"]/tig/term[matches(., "^bu.+$")]
works!
Any ideas about how I can get to use regular expressions in this query?
(4) retrieves 'bufer', 'bug' and 'bus'. If $q is 'bu', (1) retrieves as well
'attribute', 'contrast button', etc.
Thanks a lot!
Cheers, Manuel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://x-query.com/pipermail/talk/attachments/20091001/22c0df09/attachment.htm
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






