Phone Numbers

The Protector stage library includes the following category functions for phone numbers. You can use these functions only in stages included in the Protector stage library.
US_PHONE:areaCode()
Returns the area code of United States phone numbers. The area code is the first three digits of a ten digit phone number.
When a phone number does not include an area code, this function returns an empty string.
Return type: String.
For example, when evaluating 444-333-5555, this function returns 444.
US_PHONE:areaCodeOrDefault(<default value>)
Returns the area code of United States phone numbers. When the data does not include a recognizable area code, the function returns the specified default value.
Uses the following argument:
  • default value - The default value to use when the phone number does not include an area code.
Return type: String.
For example, the following expression returns the default, xxx, when evaluating 989-2222 since the phone number does not have an area code:
${US_PHONE:areaCodeOrDefault('xxx')}
US_PHONE:exchangeCode()
Returns the central office code, or exchange code, of United States phone numbers. The exchange code is the second three digits of a ten digit phone number.
Return type: String.
For example, when evaluating 444-333-5555, this function returns 333.
US_PHONE:lineNumber()
Returns the line number, or subscriber number, of United States phone numbers. The line number is the last four digits of a ten digit phone number.
Return type: String.
For example, when evaluating 444-333-5555, this function returns 5555.
US_PHONE:extension()
Returns the extension associated with United States phone numbers. This function expects the extension to be a set of numbers after the phone number, preceded by an x. This function recognizes extensions when the phone number uses one of the following formats:
<phone number>x<extension>
<phone number> x<extension>
When a phone number does not include an extension, this function returns an empty string.
Return type: String.
For example, when evaluating 444-333-5555 x123, this function returns 123.
US_PHONE:extensionOrDefault(<default value>)
Returns the extension associated with United States phone numbers. When the data does not include a recognizable extension, the function returns the specified default value. This function recognizes extensions when the phone number uses one of the following formats:
<phone number>x<extension>
<phone number> x<extension>
Uses the following argument:
  • default value - The default value to use when the phone number does not include an extension.
Return type: String.
For example, the following expression returns NA when evaluating 444-333-5555 because the number has no extension:
${US_PHONE:extensionOrDefault('NA')}
US_PHONE:std()
Returns United States phone numbers using the following standard format:
+1 (<area code>) <exchange>-<line number> [x<extension>]
such as: +1 (xxx)xxx-xxxx.
Return type: String.
For example, when evaluating 555-777-1111, this function returns +1 (555) 777-1111.
When evaluating a number with an extension, such as 555-777-1111 x 23, this function returns: +1 (555) 777-1111 x23.