Validationflags: g

US Phone Number

Match US phone numbers in common formats: (555) 867-5309, 555-867-5309, 5558675309.

Try it in RegexPro →

Available in

JavaScript / ECMAScript code

jsJavaScript
const re = new RegExp("\\(?\\d{3}\\)?[\\s.\\-]?\\d{3}[\\s.\\-]?\\d{4}", "g");
const input = "(555) 867-5309";
const matches = [...input.matchAll(re)];
console.log(matches.map(m => m[0]));

Uses `String.prototype.matchAll` for global iteration (Node 12+ / all modern browsers).

Pattern

regexengine-agnostic
\(?\d{3}\)?[\s.\-]?\d{3}[\s.\-]?\d{4}   (flags: g)

Raw source: \(?\d{3}\)?[\s.\-]?\d{3}[\s.\-]?\d{4}

How it works

The optional \(? and \)? allow parentheses around the area code. The [\s.\-]? between groups allows spaces, dots, or hyphens as optional separators.

Examples

Input

(555) 867-5309

Matches

  • (555) 867-5309

Input

555.867.5309

Matches

  • 555.867.5309

Input

5558675309

Matches

  • 5558675309

Common use cases

  • Contact form validation
  • Extracting phone numbers from documents
  • CRM data normalisation
  • Marketing list cleaning

Related patterns

Related concepts