Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

317
Views
How to format a phone number from (000) 000 - 0000 to a international phone format

Hello I have a string value of '(000) 000-0000' and I need to convert it into a string value of '+10000000000' in the international phone format. How do I go about that? Thanks. EDIT: Thank you for the quick reply. I forgot to include my previous code snippet that wasn't working for me.

  const phoneNumber = '(000) 000-0000';

  const convertedPhoNum = phoneNumber.replaceAll('\\D+', '');

  const intPhoneNumber = '+1' + convertedPhoNum;
  console.log(intPhoneNumber)

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Remove all non-numeric characters from the string, then prepend "+1":

const original = "(000) 000-0000";

const result = "+1" + original.replace(/\D/g, '');

console.log(result)

about 4 years ago · Juan Pablo Isaza Report

0

The answer by @Spectric should be fine, but you could also use a regex replace approach here:

var original = "(000) 000-0000";
var output = original.replace(/\((\d{3})\) (\d{3})-(\d{4})/, "+1$1$2$3");
console.log(original + "\n" + output);

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!