Parse a Czech Phone Number
The following sample parses a Czech phone number and logs the resulting country code, extension, national number, number of leading zeros, carrier code, and raw input.
Note:
This sample script uses the require function so you can copy it into the SuiteScript Debugger and test it. You must use the define function in an entry point script (a script you attach to a script record and deploy). For more information, see SuiteScript 2.1 Script Basics and SuiteScript 2.1 Script Types.
/**
* @NApiVersion 2.1
*/
require(['N/format/i18n'], (format) => {
const formatPhoneNumber = () => {
const origNumberStr = "602547854ext.154";
const pnParser = format.getPhoneNumberParser({
defaultCountry: format.Country.CZECH_REPUBLIC
});
const phoneNumber = pnParser.parse({
number: origNumberStr
});
const pnFormatter = format.getPhoneNumberFormatter({});
const strNumber = pnFormatter.format({
number: phoneNumber
});
return { phoneNumber, strNumber };
};
return { formatPhoneNumber };
});
Related Topics
- N/format/i18n Module Script Samples
- Format 12345 as a German String
- Format a Number as a String Using N/format/i18n
- Format Numbers as Currency Strings
- Parse a U.S. Phone Number
- Format Numbers Based on the Locale Parameter
- Format Currency Based on the Locale Parameter
- Format Numbers and Currencies Based on the English-India Locale Parameter
- SuiteScript 2.1 Modules
- SuiteScript 2.1