Skip to content

Instantly share code, notes, and snippets.

@kristopolous
Created May 9, 2017 23:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kristopolous/bfcb5b56d43dfa5a126b6864a43963e9 to your computer and use it in GitHub Desktop.
Save kristopolous/bfcb5b56d43dfa5a126b6864a43963e9 to your computer and use it in GitHub Desktop.
simple us regex phone formatter in JS
function phoneFormat(str) {
return str.replace(/[+1]*(\d{3})(\d{3})(.*)/, '1 ($1) $2-$3');
}
@kristopolous
Copy link
Author

This doesn't do anything fancy ... that's not the point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment