Convert two phone number formats into 1 phone number format

Hey everyone,

Need help with being able to convert the following phone number formats coming in via API into a single format.

The 2 formats coming in are:

+1 (416) 506-0924 and (416) 506-0924

but when I pull it from the API, I want to save it to the db as +14165060924.

I tried doing an extract with regex with the following regex that was supposed to do exactly what I described.

(?:+?1)?\D*(\d{3})\D*(\d{3})\D*(\d{4})

But it didnt do anything, the numbers remained in their initial formats.

I’m not sure if I am missing a step here.

**


**

Any help would be appreciated, thanks!

If you are certain that these are the only two formats, you can simply use find/replace operator. Get rid of +1, (, ), -, and . Then, append +1 to the beginning.

easy trick from this post:
extract with regex [+0-9]+ and then join the resulting list.
works for any country prefix

1 Like

@hergin @dorilama thank you, ill take a look at both options :slight_smile:

@dorilama @hergin I solved it via Find & Replace with Regex :slight_smile: thank you!

This topic was automatically closed after 70 days. New replies are no longer allowed.