[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Function to Extract integer from string

Subject: Re: Function to Extract integer from string
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 24 Oct 2006 14:50:52 +0100
Re:  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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.