Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > xslt 2.0 regex iterate over captured substrings ==> regex-group(n)

Reply
Thread Tools

xslt 2.0 regex iterate over captured substrings ==> regex-group(n)

 
 
RolfK
Guest
Posts: n/a
 
      06-06-2009
Dear Experts,

I got a regex which returns many captured subtrings.
My problem is that the regex is not in my hand and I need to iterate
over all cpatured substring items by the regex-group() function. This
function requires an integer argument. Unfortunately I do not know the
maximum index.

Actually I need simply to conctinate all matching substrings. But as
the max index is not known I can not do this.

What is the solution to that ?

Is there an alternative not to use xsl:analyze-string and regex-group
() ?

Tanks a lot

Rolf
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      06-07-2009
RolfK wrote:

> I got a regex which returns many captured subtrings.
> My problem is that the regex is not in my hand and I need to iterate
> over all cpatured substring items by the regex-group() function. This
> function requires an integer argument. Unfortunately I do not know the
> maximum index.
>
> Actually I need simply to conctinate all matching substrings. But as
> the max index is not known I can not do this.
>
> What is the solution to that ?


You could use a sufficiently large enough number e.g. 200 if you assume
there are not more than 200 groups and do
string-join(for $g in 1 to 200 return regex-group($g), '')
that would concatenate all subgroups from 1 to 200 and as
regex-group(someIndex) of a not existing index or not matching index
gives a zero-length string that shouldn't change the result.



--

Martin Honnen
http://msmvps.com/blogs/martin_honnen/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Iterate over group names in a regex match? Brian D Python 5 01-19-2010 06:20 PM
How to iterate 2 nested collections w <logic:iterate> without a"getter" John Java 4 04-01-2008 09:46 AM
VOIP over VPN over TCP over WAP over 3G Theo Markettos UK VOIP 2 02-14-2008 03:27 PM
nested:iterate or logic: iterate with multibox?? runescience Java 0 02-09-2006 12:57 AM
<logic:iterate /> iterate beyond items in the collection Gogo Java 1 09-04-2003 08:40 PM



Advertisments