Click to See Complete Forum and Search --> : XSL and String Manipulation


redijedi
05-07-2004, 02:35 PM
Using XSL:

How can I get the left portion of the following string from the last period?

1.4.2.3.1

becomes

1.4.2.3

substring-before only returns the string before the first period, and substring-after returns the entire string after the first period.

Any ideas?

Thanks in advance

Hp108
06-05-2004, 02:34 AM
<xsl:value-of select="substring(value,0,string-length(value)-1)" />

where:
value=1.4.2.3.1

The result: 1.4.2.3


OR

<xsl:value-of select="substring('1.2.3.4.1.5',0,string-length('1.2.3.4.1.5')-1)" />

redijedi
06-05-2004, 06:45 AM
Thanks, but I should have mentioned that the string will be unknown. That is to say that it may be 1.2.3.4.5 or 12.23 or 1234.432.24.11.3435.1234.1543.123.2321.

I found a different way around it. Ended up creating a recursive XSL template. That seemed to work.

Thanks anyway!