Created
December 11, 2017 14:54
-
-
Save cougrimes/0afe04a1f0f6481730c1f110a11b1d1a to your computer and use it in GitHub Desktop.
Standardizes all US phone number formats.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AND( | |
NOT( | |
AND( | |
LEN(Phone) == 14, | |
LEFT(Phone,1) == '(', | |
ISNUMBER(LEFT(RIGHT(Phone,13),3)), | |
LEFT(RIGHT(Phone,10),1) == ')', | |
LEFT(RIGHT(Phone,9),1) == ' ', | |
ISNUMBER(LEFT(RIGHT(Phone,8),3)), | |
LEFT(RIGHT(Phone,5),1) == '-', | |
ISNUMBER(RIGHT(Phone,4)) | |
) | |
), | |
ISNUMBER(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(Phone , ".", ''),"-",""),"+","")), | |
OR( | |
LEN(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(Phone ,".",''),"-",""),"+",""))=10, | |
AND( | |
LEN(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(Phone,".",''),"-",""),"+",""))=12, | |
LEFT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(Phone ,".",''),"-",""),"+",""),1)="+" | |
) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment