Skip to content

Instantly share code, notes, and snippets.

@iuliaL
Created October 24, 2017 08:46
Show Gist options
  • Save iuliaL/9abf9ff247da9aed1977c3ef16ac38bd to your computer and use it in GitHub Desktop.
Save iuliaL/9abf9ff247da9aed1977c3ef16ac38bd to your computer and use it in GitHub Desktop.
Regex - format a telefhone number
string = "0727937613";
string.replace(/^(\d{4})(\d{3})(\d{3})$/, "($1) $2-$3");
=> "(0727) 937-613"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment