formatUSPhoneNumber
String sutil.formatUSPhoneNumber ( String number ) (professional and enterprise editions only)
Description
Converts a String to a US formatted phone number, as +1 (123) 456-7890x2. Expects a 7 digit or 10+ digit phone number. The extension is optional, and will be any digits found after an x. This allows for extensions listed as ext, x, or extension.
Parameters
- number String containing the phone number. The only digits in this String should be the digits of the phone number.
Return Values
Returns a String formatted as a phone number, such as +1 (123) 456-7890x2, or null if the input was null
Change Log
Version | Description |
---|---|
5.5.26a | Available in all editions. |
Examples
Format a scraped phone number
// Formats the phone number extracted
String phone = sutil.formatUSPhoneNumber(dataRecord.get("PHONE_NUMBER"));
// If the extracted value had been "13334445678 ext. 23" the returned value "+1 (333) 444-5678x23"
String phone = sutil.formatUSPhoneNumber(dataRecord.get("PHONE_NUMBER"));
// If the extracted value had been "13334445678 ext. 23" the returned value "+1 (333) 444-5678x23"
mikes on 10/25/2011 at 5:08 pm
- Printer-friendly version
- Login or register to post comments