Re: [xsl] two regexp related questions

Subject: Re: [xsl] two regexp related questions
From: Brandon Ibach <brandon.ibach@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 19 May 2011 14:51:43 -0400
For 2), if you're using the regex to both validate the input (making
sure it conforms to the required syntax) and parse/extract the
name/value pairs, you might be able to make the job easier by breaking
these two tasks apart.  Use the regex as you have it now to validate
the input and then, if it matches, use a shorter regex that matches
just a single name/value pair with analyze-string to do the actual
processing.

-Brandon :)


On Thu, May 19, 2011 at 1:45 PM, Julian Reschke <julian.reschke@xxxxxx>
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>)?
>
> 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
>
> Works fine, but the regex-group function only returns values for the last
> match, so, with the example above, I can capture
>
>  a=b (because it's a non-repeating part)
>
> and
>
>  e=f
>
> I've worked around this by using recursion, feeding the "remainder" into
> another template.
>
> Is there a simpler way to achieve this?
>
> Best regards, Julian

Current Thread