xsl-list
[Top] [All Lists]

RE: [xsl] Function to Extract integer from string

2006-10-24 07:01:43
Thanks David. I think you are right. This may simplify my need to group and
sort.



-----Original Message-----
From: David Carlisle [mailto:davidc(_at_)nag(_dot_)co(_dot_)uk] 
Sent: Tuesday, October 24, 2006 9:51 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Function to Extract integer from string

  BTW, what does
  "'regex="\d+\.?\d*"' do?


\d is a digit so \d+ is one or more digits \. is a . so \.? is 0-or-1 .
and \d* is zero or more  digits

[0-9] also matches digits but with a rather anglo-saxon.ascii view of
what constitutes a digit. \d matches any unicode character with the
appropriate digit property. Still I doubt that US code of Federal
Regulations uses digits from non latin scripts so it probably comes to
the same thing in this case
                <xsl:variable name="all" select="replace(.,'[^
0-9\.]','')"/>
                <xsl:variable name="numbers" as="xs:string*">
                        <xsl:analyze-string select="$all" regex="\d+\.?\d*">
                                <xsl:matching-substring>
                                        <xsl:sequence select="."/>
                                        </xsl:matching-substring>
                                </xsl:analyze-string>
                        </xsl:variable>

I think that's just giving the sequence of numbers which you could do as

<xsl:variable name="numbers" as="xs:string*"
select="tokenize(.,'[^0-9\.]+')"/>


David

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>