Match international and domestic phone numbers using regex. Handles various formats with country codes, dashes, spaces, and parentheses.
/\+?\d{1,3}[-.\s]?\(?\d{1,4}\)?[-.\s]?\d{1,4}[-.\s]?\d{1,9}/g| Token | Meaning |
|---|---|
\+? | Optional plus sign for country code |
\d{1,3} | 1 to 3 digits (country code) |
[-.\s]? | Optional separator (dash, dot, or space) |
\(?\d{1,4}\)? | Optional parentheses around 1-4 digit area code |
\d{1,4} | 1 to 4 digits (exchange) |
\d{1,9} | 1 to 9 digits (subscriber number) |
+1-800-555-0199Match+44 20 7946 0958Match(555) 123-4567Match555.123.4567Matchabc-defgNo match12No matchconst phoneRegex = /\+?\d{1,3}[-.\s]?\(?\d{1,4}\)?[-.\s]?\d{1,4}[-.\s]?\d{1,9}/g;
const text = "Call +1-800-555-0199 or (555) 123-4567";
const matches = text.match(phoneRegex);
console.log(matches); // ["+1-800-555-0199", "(555) 123-4567"]import re
phone_regex = r'\+?\d{1,3}[-.\s]?\(?\d{1,4}\)?[-.\s]?\d{1,4}[-.\s]?\d{1,9}'
text = "Call +1-800-555-0199 or (555) 123-4567"
matches = re.findall(phone_regex, text)
print(matches) # ['+1-800-555-0199', '(555) 123-4567']Want to test this pattern with your own data?
Try this pattern in Regex Tester →