Formatting phone number in XSLT

2019-08-17 13:07发布

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条回答
家丑人穷心不美
2楼-- · 2019-08-17 13:36

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, '() ', '' )"/>
查看更多
登录 后发表回答