Created
October 24, 2014 16:20
-
-
Save CreativeNotice/9ebe66692320d2c6d053 to your computer and use it in GitHub Desktop.
Format US phone number.
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
public string function formatPhoneNumber(string phone){ | |
var clean_number = Right( ReReplaceNoCase(arguments.phone, "[^\d]", "", "ALL"), 10); | |
if( Len(clean_number) == 10){ | |
return '('& Left(clean_number,3) &') '& Mid(clean_number,4,3) &'-'& Right(clean_number,4); | |
}else{ | |
throw('Phone number is to short.', 'InvalidArgument'); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment