问题
I am having a phone number in my xml in this format like (515) 123456 and I need to have it like simple like 515123456. I used below code and it's throwing me an error
any idea how this can be done ?
<xsl:value-of
select="replace(replace(Mobile1, ') ', ''), '(', '')"
/>
回答1:
The second argument of the replace()
function is a regex pattern. Parentheses are special characters in regex, and must be escaped when used literally:
<xsl:value-of select="replace(replace(Mobile1, '\) ', ''), '\(', '')"/>
Or use simply:
<xsl:value-of select="translate(Mobile1, '() ', '' )"/>
来源:https://stackoverflow.com/questions/54143763/formatting-phone-number-in-xslt