if I have number like $999,999 I want to use a function to give me just 999999 without any other symbol.I tried substring(value,2) but that take of the $ how about the , Is there any idea to do that,
2 Answers
Use the following:
<xsl:value-of select="translate('$999,999', '$,', '')"/>
2 Comments
Saleh Makkawy
actually it works fine with me but how if the value I'm getting its attribute can I do it like this <xsl:value-of select="translate('@value', '$,', '')"/>
Linga Murthy C S
@SalehMakkawy Yes, you can.. Just get single quotes off
@value so that it is evaluated, and not considered a literal string.I'm assuming the value is actually a string, instead of a number. If you are using XPath 2.0, you can use replace (eg replace(substring(value,2), ',', '')).
If you are using XPath 1.0 (more widely supported) you can using translate (eg translate(substring(value,2), ',', '')).
1 Comment
michael.hor257k
Your approach will fail in case of a negative amount, e.g.
"-$123".