Answers for "javascript phone format string"

3

javascript function to format phone number

function formatPhoneNumber(phoneNumberString) {
  var cleaned = ('' + phoneNumberString).replace(/\D/g, '')
  var match = cleaned.match(/^(\d{3})(\d{3})(\d{4})$/)
  if (match) {
    return '(' + match[1] + ') ' + match[2] + '-' + match[3]
  }
  return null
}
Posted by: Guest on November-13-2020
0

format phone number javascript

^(\([0-9]{3}\)|[0-9]{3}-)[0-9]{3}-[0-9]{4}$
Posted by: Guest on October-26-2021

Code answers related to "javascript phone format string"

Code answers related to "Javascript"

Browse Popular Code Answers by Language