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

XQuery - RegEx Pattern Matcher

Michael Kay mike at saxonica.com
Fri Jun 19 11:20:30 PDT 2009


  XQuery - RegEx Pattern Matcher
The XPath regular expression language does not recognize \G and it does not
recognize non-capturing groups. 

As far as matches() is concerned, there is no distinction between capturing
and non-capturing groups, so replace "(?:" by "(".

I suspect you wanted your regex to contain "\G". In Java you need to escape
this as "\\G"; in XPath/XQuery, backslash is not a special character and
does not need to be escaped. However, there's no "\G" in XPath regular
expressions anyway. In Java it means "the end of the previous match"; but
XQuery is a functional language, so "previous" is meaningless. At this stage
I give up because I'm not sure what you are trying to do: you haven't
supplied enough of your code.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay  

> -----Original Message-----
> From: http://x-query.com/mailman/listinfo/talk 
> [mailto:http://x-query.com/mailman/listinfo/talk] On Behalf Of http://x-query.com/mailman/listinfo/talk
> Sent: 19 June 2009 09:33
> To: http://x-query.com/mailman/listinfo/talk
> Subject:  XQuery - RegEx Pattern Matcher
> 
> Hi,
> I am trying to use a RegEx within XQuery. In general that works fine.
> Now I have a more complex RegEx to work with CSV-files(these 
> CSV have ";" as separator).
> I use can the following without problems in Java :
> 
> Pattern Regex = Pattern.compile(
> "\\G(?:^|;)(?:\"((?:[^\"]|\"\")*)\"|([^\";]*))");
> ...
> 
> But in XQuery
> let $regularExpr :='\\G(?:^|;)(?:\"((?:[^\"]|\"\")*)\"|([^\";]*))'
> ...
> if (matches($row,$regularExpr) ) then ( ...
> 
> just gives the error :
> 
> Error at character 4 in regular expression 
> "\\G(?:^|;)(?:\"((?:[^\"]|\"\")...": expected ())
> 
> 
> I tried the optional flags (i, x, ...) but always with the 
> same result...
> What is wrong with this RegEx ?
> 
> P.S. :I run the XQuery from Java with Saxon.
> 
> 
> --
> GMX FreeDSL Komplettanschluss mit DSL 6.000 Flatrate und 
> Telefonanschluss für nur 17,95 Euro/mtl.!* 
> http://portal.gmx.net/de/go/dsl02 
> _______________________________________________
> http://x-query.com/mailman/listinfo/talk
> http://x-query.com/mailman/listinfo/talk




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.