Parse phone number

Supported in: Batch, Streaming

Resolves and normalizes phone numbers.

Expression categories: String

Declared arguments

  • Expression - Phone number to parse.
    Expression<String>
  • Format - Desirable phone number format.
    Enum<E164, E164_DIGITS_ONLY, INTERNATIONAL, NATIONAL, RFC3966>
  • optional Region - Region the phone number belongs to. Note: when region is not specified, parsing will be performed without it, which could lead to inaccurate or no result at all. This might be useful in case you have a variety of numbers and a single region cannot be assigned.
    Enum<Afghanistan, Albania, Algeria, American Samoa, Andorra, Angola, Anguilla, Antigua and Barbuda, Argentina, Armenia, and more ...>

Output type: Phone Number

Examples

Example 1: Base case

Description: Should return parsed number in the E164 with digits only format. Argument values:

  • Expression: +1 415 5552671
  • Format: E164_DIGITS_ONLY
  • Region: US

Output: 14155552671


Example 2: Base case

Description: Should return parsed number in the E164 format. Argument values:

  • Expression: +1 415 5552671
  • Format: E164
  • Region: US

Output: +14155552671


Example 3: Base case

Description: Should return parsed number in the the INTERNATIONAL format. Argument values:

  • Expression: +1 415 5552671
  • Format: INTERNATIONAL
  • Region: US

Output: +1 415-555-2671


Example 4: Base case

Description: Should return parsed number in the the NATIONAL format. Argument values:

  • Expression: +1 415 5552671
  • Format: NATIONAL
  • Region: US

Output: (415) 555-2671


Example 5: Base case

Description: Should return parsed number in the the RFC3966 format. Argument values:

  • Expression: +1 415 5552671
  • Format: RFC3966
  • Region: US

Output: tel:+1-415-555-2671


Example 6: Base case

Description: Return formatted US phone number Argument values:

  • Expression: phoneNumber
  • Format: E164
  • Region: US
phoneNumberOutput
(234) 235-5678+12342355678
+1 415 5552671+14155552671
(415) 5552671+14155552671
Whatsapp@14155552671+14155552671

Example 7: Null case

Description: Return null when phone number is un-parsable Argument values:

  • Expression: phoneNumber
  • Format: E164
  • Region: null
phoneNumberOutput
nullnull
9991-COMPANYnull
empty stringnull

Example 8: Edge case

Description: Tries to parse number only based on the number itself. Region not specified Argument values:

  • Expression: phoneNumber
  • Format: E164
  • Region: null
phoneNumberOutput
(234) 235-5678null
+1 415 5551111+14155551111
1 415 555 1111null
+1 411 1111111null
+34 91 23 45678+34912345678
Whatsapp@34912345678null