Re: [xsl] A better xsl:analyze-string

Subject: Re: [xsl] A better xsl:analyze-string
From: Pavel Minaev <int19h@xxxxxxxxx>
Date: Thu, 20 Aug 2009 18:16:26 -0700
On Thu, Aug 20, 2009 at 5:29 PM, Michael Sokolov<sokolov@xxxxxxxxxxxx> wrote:
> I like the avoidance of the clumsy numbered capture groups, (my
non-starting
> proposal would be to add perl capture variables ala
$1,$2,$3,$@,$'$`,etc...)
>
> But how would you retrieve the value of the matching subgroup (the decimal
> portion) in:
> <xsl:matching-substring regex="\d+(\.\d*)?">

Same way as you can do it now: regex-group(1). The only difference is
that group indices are local for each matching-substring/@regex.

In general, however, in scenarios where you'd typically use this, you
would not care about subgroups. See below.

> There's something asymmetric about your proposal that bothers me.  There
are
> other cases of combining multiple capture groups that wouldn't get the same
> special treatment (like the nesting in the example).  Why assume that
> capture groups are always combined as (...)|(...)?  It's a very special
> case: is it so common as to warrant special syntax?

It is definitely a special case, but I believe it is a fairly common
and broad one: it is a general-purpose tokenizing lexer, the analog of
lex/flex in XSLT.

Current Thread