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

Re: Filter leading numbers out of Strings

Subject: Re: Filter leading numbers out of Strings
From: Rolf Leopold <leopoldmail@xxxxxx>
Date: Tue, 07 Nov 2006 22:49:46 +0100
get numbers out of strings
Hi Michael,

thank`s a lot for your help.
After your advice i realised that i only meant the leading numbers of any other characters without the trailing numbers.
Anyhow, here ist my solution based on your hint:
<xsl:variable name="stringJunK" select="translate($String,'0123456789','')"/>(filter out all numbers)
<xsl:variable name="firstCharacterOfJunK" select="substring($stringJunK,1,1)"/>(Get the first character of the non-numbers)
<xsl:variable name="leadingNumbers" select="substring-before($String,$firstCharacterOfJunK)"/>(get the numbers before the first non-number sign)
(Exception:Only numbers, where i use an additional if-query).


Cheers,
Rolf

Michael Kay schrieb:
You say leading numbers, but you don't give an example with a trailing
number. What do you want to happen to 123ABC789?

Also, the non-numeric parts of your strings contain A-Z only. Is that a
feature of the data, or just an accident of your examples?

You can handle your examples with translate($in, 'ABCDE...Z', '').

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

-----Original Message-----
From: leopoldmail@xxxxxx [mailto:leopoldmail@xxxxxx] Sent: 06 November 2006 07:01
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Filter leading numbers out of Strings


Hi,

i have stings in different length with leading numbers in an XML-File which i want to transform into another XML-File:
Is it possible to only filter out leading numbers of the strings without using a recursive template and without using xsl2.0?
For example:
"1234AB" should be "1234"
"123456ABC" should be "123456"
"123456789A" should be "123456789"


thank`s a lot for any help,
Rolf

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.