Format Phone Numbers

I’d like an extension that changes a selected string of characters into a standard format for a phone number (if exactly 10 digits other than the optional leading country code are in the string) and adds the county code with plus sign (“+”) if it is not already present.

Examples:

“(123) 456-7890” → “+1 123.456.7890”
“123-456-7890” → “+1 123.456.7890”
“123.456.7890” → “+1 123.456.7890”
“1234567890” → “+1 123.456.7890”
“+1123-456-7890” → “+1 123.456.7890”
“1 123-456-7890” → “+1 123.456.7890”
“123-456-789” → does nothing

Having a setting for different countries is icing on the cake; I personally need it for the United States only but having different rules for different countries would be very cool.

Thank you for reading this idea.

Share the extension, if you don’t mind.

1 Like