Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

google-libphonenumber

node v9.11.2
version: 2.0.0
endpointsharetweet
let nr = '06 - 83164677' let country = 'NL' const phoneno = '+' + nr.replace(/[^0-9\-\(\)+]+/g, '').trim().replace(/^[0+]+/, '') console.log(phoneno) const phoneUtil = require('google-libphonenumber').PhoneNumberUtil.getInstance() const number = phoneUtil.parseAndKeepRawInput(phoneno) console.log(number.getCountryCode()) if (phoneUtil.isValidNumber(number)) { console.log("valid") console.log(phoneUtil.format(number, require('google-libphonenumber').PhoneNumberFormat.E164)) } else { console.log("invalid, try with country", country) const numbercc = phoneUtil.parseAndKeepRawInput(nr, country) console.log(phoneUtil.format(numbercc, require('google-libphonenumber').PhoneNumberFormat.E164)) } //
Created from: https://npm.runkit.com/google-libphonenumber
Loading…

no comments

    sign in to comment