Regex for US phone number

/(?:\+1[\s.-]?)?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}\b/g

Options
Matches

Examples

Note

Matches common North American formats. For anything international, store numbers in E.164 and validate with a phone library.

Matches in the example

  • "(555) 123-4567"
  • "555.123.4567"
  • "+1 555 123 4567"

Token by token

  1. (?: a group, not capturing
  2. \+ the character “+”
  3. 1 the character “1”
  4. [\s.-]? one of: a whitespace character, “.” or “-”, optionally
  5. )? end of group, whole group optionally
  6. \(? the character “(”, optionally
  7. \d{3} a digit (0–9), exactly 3 times
  8. \)? the character “)”, optionally
  9. [\s.-]? one of: a whitespace character, “.” or “-”, optionally
  10. \d{3} a digit (0–9), exactly 3 times
  11. [\s.-]? one of: a whitespace character, “.” or “-”, optionally
  12. \d{4} a digit (0–9), exactly 4 times
  13. \b a word boundary

Other patterns