Phone number conversion. Separate prefix in brackets

There is an element: <phone>(987) 123-45-67</phone>

.

You must convert it to: <span><small>(987)</small>&#160;123-45-67</span>

.

How can I do that?

+2


a source to share


1 answer


<span>
  <small>
    <xsl:value-of select="concat(substring-before(phone, ')'), ')')" />
  </small>
  <xsl:text>&#160;</xsl:text>
  <xsl:value-of select="normalize-space(substring-after(phone, ')'))" />
</span>

      



The above will not work for phone numbers in any other format than the one you are showing. Add your own health check to make sure the phone number is in the expected format.

+2


a source







All Articles