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

RE: [XSLT 1.0] How to get the last number in a string

Subject: RE: [XSLT 1.0] How to get the last number in a string of numbers?
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 23 Dec 2009 23:53:45 -0000
RE:  [XSLT 1.0] How to get the last number in a string
You can write a recursive named template that extracts the last character of
the string, repeatedly until the last character is a non-digit.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay  

> -----Original Message-----
> From: Costello, Roger L. [mailto:costello@xxxxxxxxx] 
> Sent: 23 December 2009 14:02
> To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
> Subject:  [XSLT 1.0] How to get the last number in a 
> string of numbers?
> 
> 
> Hi Folks,
> 
> I have a variable that contains a bunch of numbers:
> 
>    <xsl:variable name="numbers">
>       generate some numbers
>    </xsl:variable>
> 
> I want to obtain the last number in $numbers.
> 
> For example, this might be the value of $numbers:
> 
>    6 23 45 67
> 
> I want the last number:
> 
>    67
> 
> I want the last number fast, i.e., I want it in constant 
> time, not O(n), where n is the length of the list of numbers.
> 
> Plus, I don't want to use any extension functions/elements.
> 
> Finally, I want to use only XSLT 1.0
> 
> Can it be done? How? 
> 
> /Roger

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-2013 All Rights Reserved.