Reputation: 43
I am looking for this solution in xslt 2.0:
Input: +47(12)1234567
Output: +47121234567
I tried to use this:
replace(replace('$Input', '(',''), ')','')
But it throws an error as '(' and ')' are unable to be escaped with the above code.
Please can some one point out the correct solution.
Thank you.
Upvotes: 1
Views: 2614
Reputation: 1816
Use this: <xsl:value-of select="replace($input, '\(|\)','')"/>
Upvotes: 0
Reputation: 167716
I would put both characters into square brackets in a single replace
call replace($input, '[()]', '')
.
Upvotes: 3
Reputation: 1009
Parentheses are reserved characters in regex, which is what the replace function takes as argument.
The easiest solution is to use translate()
, in this case:
<xsl:value-of select="translate('+47(12)1234567', '()', '')"/>
Alternatively, you can escape the parentheses with a backslash.
Upvotes: 1