Formatting phone number in XSLT

佐手、 提交于 2019-12-11 15:38:13

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!