Regex for phone numbers (US-style)

Example pattern below—edit it or paste your own. All processing runs in your browser. For Python’s re module, switch flavor in the tool.

Flavor

Standard `RegExp` for explanation and preview.

g i m s u y d v (JavaScript)
Call 555-123-4567, (555) 987-6543, or +1 202 555 0199.

Plain-English explanation

Flavor: JavaScript RegExp

Flags: g (find all matches)

a word boundary Then Match (non-capturing): Match the character "+", optional. Then Match the character "1". Then Match one character from: the character "-", the character ".", whitespace character, optional, optional. Then Match the character "(", optional. Then Match digit character (0–9), repeated exactly 3 times. Then Match the character ")", optional. Then Match one character from: the character "-", the character ".", whitespace character, optional. Then Match digit character (0–9), repeated exactly 3 times. Then Match one character from: the character "-", the character ".", whitespace character, optional. Then Match digit character (0–9), repeated exactly 4 times. Then a word boundary

More examples

Back to RegExplain