PhoneNumberParser.parse(options)

Method Description

Parses the string containing the phone number and returns the phone number object.

If the input string contains the country code, it parses the given phone number. If the input string does not contain the country code, the country given to PhoneNumberParser as constructor parameter is used.

Returns

Object

Supported Script Types

Client and server scripts

For more information, see SuiteScript 2.x Script Types.

Governance

None

Module

N/format/i18n Module

Parent Object

format.PhoneNumberParser

Methods and Properties

Phone Number Parser Object Members

Since

2020.2

Parameters

Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

options.number

string

required

The string to be parsed.

Syntax

Important:

The following code snippet shows the syntax for this member. It is not a functional example. For a complete script example, see N/format/i18n Module Script Samples.

            // Add additional code
...
var pnParser = format.getPhoneNumberParser({
    defaultCountry: format.Country.CZECH_REPUBLIC
});
var phoneNumber = pnParser.parse({
    number: "602547854ext.154"
});
/* expected parsed output:
   phoneNumber.countryCode = 420
   phoneNumber.extension = 154
   phoneNumber.nationalNumber = 602547854
   phoneNumber.numberOfLeadingZeros = 1
   phoneNumber.carrierCode = (blank)
   phoneNumber.rawInput = 602547854ext.154
*/
...
// Add additional code 

          

Related Topics

N/format/i18n Module
Phone Number Formatter Object Members
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices