XSL Analyze-String -> Matching-Substring into multiple variables

Viewed 6072

I was wondering if it is possible to use analyze-string and set multiple groups within the RegEx and then store all of the matching groups in variables to use later on.

like so:

<xsl:analyze-string regex="^Blah\s+(\d+)\s+Bloo\s+(\d+)\s+Blee" select=".">
  <xsl:matching-substring>
    <xsl:variable name="varX">
      <xsl:value-of select="regex-group(1)"/>
    </xsl:variable>                                
    <xsl:variable name="varY">
      <xsl:value-of select="regex-group(2)"/>
    </xsl:variable>        
  </xsl:matching-substring>
</xsl:analyze-string>    

This doesn't actually work, but that's the sort of thing I'm after, I know I can wrap the analyze-string in a variable, but that seems daft that for every group I have to process the RegEx, not very efficient, I should be able to process the regex once and store all of the groups for use later on.

Any ideas?

2 Answers
Related