1

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,

0

2 Answers 2

2

Use the following:

<xsl:value-of select="translate('$999,999', '$,', '')"/>
Sign up to request clarification or add additional context in comments.

2 Comments

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', '$,', '')"/>
@SalehMakkawy Yes, you can.. Just get single quotes off @value so that it is evaluated, and not considered a literal string.
0

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

Your approach will fail in case of a negative amount, e.g. "-$123".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.