[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

Regular Expression search

Michael Kay mhk at mhk.me.uk
Thu Dec 15 00:08:30 PST 2005


inurl 000961.html
Use
 
//*[matches(., "Name")]
 
But of course this could be done equally well using the simpler contains()
function. The matches() function comes into its own with a more complex
expression such as
 
//*[matches(., "^(My|Your) Name")]
 
which requires the string to start with "My Name" or "Your Name".
 
Of course //* would be better replaced by a more specific expression. In
fact you want to be careful with this because with a schema-aware query, the
above expression could give you a type error: it will fail when you apply
the predicate to an element that has element-only content.
 
I have a feeling you might be asking "how do I write regular expressions".
There are a few tutorials around - try for example
http://www.zvon.org/other/PerlTutorial/Output/ There are a few differences
between regular expressions in say Perl or Python and regular expressions in
XPath 2.0, but you can get through the first 20 or so examples in this
tutorial before you hit them.
 
Michael Kay
http://www.saxonica.com/


  _____  

From: http://xquery.com/mailman/listinfo/talk [mailto:http://xquery.com/mailman/listinfo/talk] On Behalf Of
Elarrat, EFC
Sent: 14 December 2005 18:24
To: http://xquery.com/mailman/listinfo/talk
Subject: Re:  Regular Expression search


Me again...just trying to know the following:
 
<tagA>
    <subTagA>My Name Is Eduardo</subTagA>
</tagA>
<tagB>
    <subTagB>My Name Is Elarrat</subTagB> //Corrected! =)
</tagB>
 
I saw the matches function and I got it well (I think...), but could anybody
please give me an example of how to use the matches function on this case?
like, searching for all tags that contains "Name"? Like "Name*" or "*Name"? 
 
If somebody doesn't understand, please ask Howard to translate it for you =)
 
Thanks a lot
 
Eduardo Elarrat

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://xquery.com/pipermail/talk/attachments/20051215/8b0d4ac6/attachment.htm


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.