[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: two regexp related questions

Subject: Re: two regexp related questions
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Thu, 19 May 2011 22:36:42 +0100
Re:  two regexp related questions
On 19/05/2011 18:45, Julian Reschke wrote:
Hi there,

I've got two regexp-related questions.

1) Is it correct that XSLT/XPath2's regular expressions do not support non-capturing groups (as shown in <http://www.exampledepot.com/egs/java.util.regex/NoGroup.html>)?

Yes. This is being added in 3.0.

2) With respect to analyze-string, and the captured regex-groups:


I'm using a regex like

([A-Z]+) = ([A-Z]+) ( ; ([A-Z]+) = ([A-Z]+) )*

for matching things like

a=b;c=d;e=f


Why not use the regex


([A-Z]+) = ([A-Z]+)

and rely on xsl:matching-substring being called multiple times?

Alternatively, first use tokenize() to split on the semicolons, and then put each token through xsl:analyze-string.

Personally, I find long regexes very difficult to get right, and try to split the task up into small pieces that I can understand and debug.

Michael Kay
Saxonica

Current Thread

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-2013 All Rights Reserved.