# pdk.util.PhoneNumberUtil

Set of util functions to operate with phone numbers

## Functions

* parse

***

### parse

Parses a string and returns it as a phone number. The method is quite lenient and looks for a number in the input text (raw input) and does not check whether the string is definitely only a phone number. To do this, it ignores punctuation and white-space, as well as any text before the number (e.g. a leading "Tel: ") and trims the non-number bits. It will accept a number in any format (E164, national, international etc), assuming it can be interpreted with the defined region supplied. It also attempts to convert any alpha characters into digits if it thinks this is a vanity number of the type "1800 MICROSOFT".

Arguments:

* phoneNumber :: [pdk.core.String](https://processmix.gitbook.io/guide/structures/pdk.core#string) - number that we are attempting to parse. This can contain formatting such as +, ( and -, as well as a phone number extension. It can also be provided in RFC3966 format.
* region :: [pdk.core.String](https://processmix.gitbook.io/guide/structures/pdk.core#string) - region that we are expecting the number to be from. This is only used if the number being parsed is not written in international format. The country\_code for the number in this case would be stored as that of the default region supplied. If the number is guaranteed to start with a '+' followed by the country calling code, then RegionCode.ZZ (like 'US or 'NL') or null can be supplied.
* format :: [pdk.core.String](https://processmix.gitbook.io/guide/structures/pdk.core#string) - the format the phone number should be formatted into.&#x20;

  Can be:

  * E164
  * INTERNATIONAL
  * NATIONAL
  * RFC3966

  INTERNATIONAL and NATIONAL formats are consistent with the definition in ITU-T Recommendation E123. For example, the number of the Google Switzerland office will be written as "+41 44 668 1800" in INTERNATIONAL format, and as "044 668 1800" in NATIONAL format. E164 format is as per INTERNATIONAL format but with no formatting applied, e.g. "+41446681800". RFC3966 is as per INTERNATIONAL format, but with all spaces and other separating symbols replaced with a hyphen, and with any phone number extension appended with ";ext=". It also will have a prefix of "tel:" added, e.g. "tel:+41-44-668-1800".&#x20;

Result:

* output :: [pdk.core.String](https://processmix.gitbook.io/guide/structures/pdk.core#string) - the formatted phone number.

Possible exceptions

* [NullPointerException](https://processmix.gitbook.io/guide/specification/exceptions/runtime-exceptions#nullpointerexception) - throws if phoneNumber or format argument is `NULL`
