This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: substrings and identical numbers
- To: tobi02 <tobiasreif at pinkjuice dot com>
- Subject: Re: [xsl] substrings and identical numbers
- From: Jeni Tennison <mail at jenitennison dot com>
- Date: Wed, 9 May 2001 18:48:20 +0100
- CC: XSL-List at lists dot mulberrytech dot com
- Organization: Jeni Tennison Consulting Ltd
- References: <3AF96A89.D540DB7E@pinkjuice.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi Tobi,
> <!-- I need to get the first three places. They can be of any
> length. Why does only the second one work like expected? The first
> one doesn't work if the two numbers are the same. (uncomment one
> then the other) -->
Just to explain why the first one doesn't work, take the string:
a_a_7000_7000
You have the expression:
substring-before($input,
substring-after(
substring-after(
substring-after($input, '_'), '_'), '_'))
Substituting in the $input:
substring-before('a_a_7000_7000',
substring-after(
substring-after(
substring-after('a_a_7000_7000', '_'),
'_'), '_'))
Evaluating the inner-most substring-after():
substring-before('a_a_7000_7000',
substring-after(
substring-after('a_7000_7000', '_'), '_'))
Evaluting the inner-most substring-after():
substring-before('a_a_7000_7000',
substring-after('7000_7000', '_'))
And evaluating that last substring-after():
substring-before('a_a_7000_7000', '7000')
The substring-before() function finds the first occurrence of the
second argument string in the first argument string, and returns the
string that occurs before it. The first occurrence of the string
'7000' in the string 'a_a_7000_7000' is the first '7000' in that
string, so the substring-before() is:
'a_a_'
I hope that helps,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list