I just want to format phone numbers without area code and dashes just the extract the 10 digits number.
For example when I extracted this phone number +1 336-207-0212 and added it into the google sheet it becomes an error. I figured it out added =”Phonenumber”, but for my next automation the phone number needs to be 3362070212. Is there any way to extract the 10 digits number even if the area code is different it might be +1 next it is +63.
I’m sure there are great APIs out there to format phone numbers in various ways.
Nowadays for a task like this I’d use an AI Model. You can use the Make AI Content Extractor or Gemini’s ‘Extract Structured Data’ module to do so or any other AI Model provider
If you try a few prompts you’ll find one that converts the number reliably.
In the Set Variable module, I set up a phone number. On one hand I tried your phone number with +1, and on the other hand +63, they both work with this formula:
However, I did some research, and area codes can (in some countries), take multiple digits. So this will not work for an area code of 3 digits or more. I already have an idea on how to fix that, but for now you can use this if your area codes only have 1 or 2 digits. For the general solution I will assume that **all your phone numbers have a space between the area code and the 10 digit number you want to retrieve, right?**
Hope this helps, I will be back with you with the general solution
Remember, this assumes a space to always occur between the area code and the 10 digit number, and the phone number to exist. If this is not the case, the formula won’t work for the cases that do not match my assumptions.
If there are other formats possible, there are still solutions possible, I just need to know every possible format that the phone numbers can be in.
This is the code copied right from my Make scenario:
{{replace(substring(1.Phone number; indexOf(1.Phone number; space); length(1.Phone number)); “-”; emptystring)}}
If you know the length of the phone number, just use the {{substring({{number}};<start>;<end>)}} function when inserting the value with the Google Sheets app. However, this does not work for all international numbers, as lengths vary. In North America you have the 3-3-4 pattern. In Brazil, for example, it can be 2-5-4 OR 2-4-4.
If this should match any international phone number, you may add another step to retrieve only the international prefix and then remove it from the string. Add another Text parser with the pattern ^+(\d+)(?=\D) and it will give you the number(s) after + and before any non-digit character (space, parenthesis, dash etc). OR, use Bundle 1 from the previous match, if you are sure the number always contains an international prefix. Then, subtract its length from the whole string and you’ll have your number.