title: find number in string with regex + xslt
body: <p>I'm trying to fetch the amount of comments out of the description of the following XML code:</p>
  
  <pre><code>    &lt;item&gt;
          &lt;title&gt;War Stats&lt;/title&gt;
          &lt;link&gt;http://www.reddit.com/r/politics/comments/r3p6r/war_stats/&lt;/link&gt;
          &lt;guid isPermaLink="true"&gt;http://www.reddit.com/r/politics/comments/r3p6r/war_stats/&lt;/guid&gt;
          &lt;pubDate&gt;Mon, 19 Mar 2012 10:30:01 -0700&lt;/pubDate&gt;
          &lt;description&gt;submitted by &amp;lt;a href="http://www.reddit.com/user/focusing"&amp;gt; focusing &amp;lt;/a&amp;gt; to &amp;lt;a href="http://www.reddit.com/r/politics/"&amp;gt; politics&amp;lt;/a&amp;gt; &amp;lt;br/&amp;gt; &amp;lt;a href="http://i.imgur.com/8HpWg.jpg"&amp;gt;[link]&amp;lt;/a&amp;gt; &amp;lt;a href="http://www.reddit.com/r/politics/comments/r3p6r/war_stats/"&amp;gt;[634 comments]&amp;lt;/a&amp;gt;&lt;/description&gt;
      &lt;/item&gt;
  </code></pre>
  
  <p>as you can see I want to fetch the number 634 out of it and put it into a 'score' attribute of a new xml file</p>
  
  <pre><code>&lt;xsl:attribute name="score"&gt;
      &lt;xsl:analyze-string select='description' regex='\d'&gt;
          &lt;xsl:matching-substring&gt;
              &lt;number&gt;&lt;xsl:value-of select='.' /&gt;&lt;/number&gt;
          &lt;/xsl:matching-substring&gt;
      &lt;/xsl:analyze-string&gt;
  
  &lt;/xsl:attribute&gt;
  </code></pre>
  
  <p>but I think I'm doing it wrong..</p>
  
  <p>this is the entire code:
      </p>
  
  <pre><code>&lt;xsl:stylesheet version="2.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:a="http://www.w3.org/2005/Atom"
  xmlns:media='http://search.yahoo.com/mrss/'&gt;
  
  
  &lt;xsl:template match="/"&gt;
  
  &lt;xsl:for-each select="/rss/channel/item"&gt;
  &lt;item&gt;
      &lt;xsl:attribute name="type"&gt;reddit&lt;/xsl:attribute&gt;
      &lt;xsl:variable name="redditTitle" content="title" /&gt;
      &lt;xsl:attribute name="name"&gt;
          &lt;xsl:if test="string-length(title) &amp;gt; 50"&gt;
              &lt;xsl:value-of select="concat(substring(title, 1, 75), '...')" /&gt;    
          &lt;/xsl:if&gt;
          &lt;xsl:if test="string-length(title) &amp;lt; 50"&gt;
              &lt;xsl:value-of select="title" /&gt;
          &lt;/xsl:if&gt;
      &lt;/xsl:attribute&gt;
  
      &lt;xsl:attribute name="url"&gt;
          &lt;xsl:value-of select="link" /&gt;
      &lt;/xsl:attribute&gt;
  
      &lt;xsl:attribute name="image"&gt;http://dl.dropbox.com/u/8226356/Unief/DatabasesWebtechnologie/Praktijk/Project/Reddit_logo.thumbnail.png&lt;/xsl:attribute&gt;
  
      &lt;xsl:attribute name="score"&gt;
          &lt;xsl:analyze-string select='description' regex='[0-9]+'&gt;
              &lt;xsl:matching-substring&gt;
                  &lt;xsl:value-of select='.' /&gt;
              &lt;/xsl:matching-substring&gt;
          &lt;/xsl:analyze-string&gt;
  
      &lt;/xsl:attribute&gt;
  &lt;/item&gt;
  &lt;/xsl:for-each&gt;
  
  &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>Can someone explain me how to do it right?</p>