Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1104589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:30:19+00:00 2026-05-17T01:30:19+00:00

I need to convert incoming phone number strings to a standardized format that does

  • 0

I need to convert incoming phone number strings to a standardized format that does not have any non-numeric characters and strips off the leading number if it is 1.

For example:

“+1 (222) 333-4444 x 5555” becomes “22233344445555”

Thanks in advance for your help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T01:30:19+00:00Added an answer on May 17, 2026 at 1:30 am

    I. XSLT 1.0 solution:

    This transformation:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output method="text"/>
    
     <xsl:template match="text()">
      <xsl:variable name="vnumsOnly" select=
      "translate(., translate(.,'0123456789',''), '')
      "/>
    
      <xsl:value-of select=
      "substring($vnumsOnly, (substring($vnumsOnly,1,1)='1') +1)"/>
     </xsl:template>
    </xsl:stylesheet>
    

    when applied on this XML document:

    <t>"+1 (222) 333-4444 x 5555</t>
    

    produces the wanted, correct result:

    22233344445555
    

    Explanation:

    1. The expression: translate(.,'0123456789','') is evaluated to a string that contains all non-numeric characters in the current node.

    2. We use 1. above in the expression:

      translate(., translate(.,’0123456789′,”), ”)

    and this evaluates to a string where all non-numeric characters from the current node are deleted.

    .3. The expression: (substring($vnumsOnly,1,1)='1') +1)" evaluates to 2 if the first character of $vnumsOnly is '1' and it evaluates to 1 if the starting character isn’t ‘1’.

    .4. We use 3. in the following expression:

    substring($vnumsOnly, (substring($vnumsOnly,1,1)='1') +1)
    

    which evaluates to the same string $vnumsOnly if it doesn’t start with ‘1’ and it evaluates to its substring starting from the 2nd character, if the first character is ‘1’.


    II. XPath 2.0 solution:

    Just use:

    replace(replace(., '[^0-9]', ''), '^1', '')
    

    The inner replace removes all characters that aren’t 0 through 9 (digits). The outer replace removes the leading 1 (if it exists).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a date that I need to convert using PHP date. I've tried
I have a form using jQuery that I need to manipulate the incoming data.
Hi I have the following class and need to convert the incoming Json using
I need to convert a string vector in a simple string. I do not
I need to convert a Joda-Time DateTime into a String, in the following format:
I writing simple application that need to make some record of the incoming sound.
I have a field varchar(14) = 20090226115644 I need convert it to -> 2009-02-26
Need to convert a string to normal datetime format so it can be correctly
I need to convert a shapefile/ kml to encoded polyline format for a certain
Equivalent to utf8_decode in php I have an string: tópicos I need convert to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.