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

Discussion in 'XML' started by RolfK, Jun 6, 2009.

  1. RolfK

    RolfK Guest

    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
     
    RolfK, Jun 6, 2009
    #1
    1. Advertising

  2. 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/
     
    Martin Honnen, Jun 7, 2009
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gogo
    Replies:
    1
    Views:
    2,140
    Sudsy
    Sep 4, 2003
  2. runescience
    Replies:
    0
    Views:
    1,494
    runescience
    Feb 9, 2006
  3. coosa
    Replies:
    7
    Views:
    2,774
    Jeff Dillon
    May 2, 2006
  4. John
    Replies:
    4
    Views:
    955
    RedGrittyBrick
    Apr 1, 2008
  5. Brian D
    Replies:
    5
    Views:
    2,943
Loading...

Share This Page