The easiest way to match both

^\([0-9]{3}\)[0-9]{3}-[0-9]{4}$

and

^[0-9]{3}-[0-9]{3}-[0-9]{4}$

is to use alternation ((...|...)): specify them as two mostly-separate options:

^(\([0-9]{3}\)|[0-9]{3}-)[0-9]{3}-[0-9]{4}$

By the way, when Americans put the area code in parentheses, we actually put a space after that; for example, I'd write (123) 123-1234, not (123)123-1234. So you might want to write:

^(\([0-9]{3}\) |[0-9]{3}-)[0-9]{3}-[0-9]{4}$

(Though it's probably best to explicitly demonstrate the format that you expect phone numbers to be in.)

Answer from ruakh on Stack Overflow
Discussions

REGEX Tutorial to Validate US Phone Numbers
Hi everyone, I wanted to create this discussion post to share a methodology I created using Domo's Regular Expressions in Magic ETL to parse and validate US phone numbers. This validation process follows the basic standards set by the North American Numbering Plan (NANP) and helps identify ... More on community-forums.domo.com
🌐 community-forums.domo.com
March 26, 2025
US Phone Number Validation - Help Needed
I got a regex from Stack Overflow for phone number validation, but it doesn’t get all of the tests to pass. The test results are: telephoneCheck("1 555-555-5555") should return true. telephoneCheck("1 (555) 555-5555") should return true. telephoneCheck("1(555)555-5555") should return true. ... More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
0
0
July 26, 2020
Regex for US phone number
Yea, a tough one. To debug it’s easier to copy paste the test specs from the left to after the function and console.log. Also it’s easier to use string .match method and console.log to see what is captured from the string using your regex. See below: · This topic was automatically closed ... More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
0
0
December 3, 2021
help with regex validation for worldwide email, phone numbers and address
Create a short answer question for the phone number. Click on the three dots (⋮) at the bottom right of the question field and select "Response validation." In the dropdown that appears, select "Regular expression." Choose "Matches" from the next dropdown. Paste the regex pattern into the text field. Add a custom error message if desired, such as "Please enter a valid phone number starting with a + followed by the country code and number." ^\+([0-9]{1,4})[-\s]?([0-9]{1,15})$ This regex should cover a wide range of international phone numbers, but keep in mind that certain country-specific formatting might not be fully captured due to the flexibility required for worldwide usage. If you encounter any specific cases where the regex fails, you may need to adjust the pattern slightly. More on reddit.com
🌐 r/GoogleForms
3
2
July 31, 2024
🌐
GitHub
gist.github.com › jengle-dev › a327f2b58e08f384ec41dbb5e5454c28
RegEx Phone Number Matching & Validation · GitHub
This 'Regular Expression' (RegEx) is used to match and validate US phone numbers in the following formats, where X represents digits (d):
🌐
O'Reilly
oreilly.com › library › view › regular-expressions-cookbook › 9781449327453 › ch04s02.html
4.2. Validate and Format North American Phone Numbers - Regular Expressions Cookbook, 2nd Edition [Book]
August 27, 2012 - You want to determine whether a user entered a North American phone number, including the local area code, in a common format. These formats include 1234567890, 123-456-7890, 123.456.7890, 123 456 7890, (123) 456 7890, and all related combinations.
Authors   Jan GoyvaertsSteven Levithan
Published   2012
Pages   609
🌐
Domo
community-forums.domo.com › home › community forums › magic etl
REGEX Tutorial to Validate US Phone Numbers - Domo Community Forum
March 26, 2025 - Hi everyone, I wanted to create this discussion post to share a methodology I created using Domo's Regular Expressions in Magic ETL to parse and validate US phone numbers. This validation process follows the basic standards set by the North American Numbering Plan (NANP) and helps identify valid US phone numbers from a…
🌐
Medium
thetechplatform.medium.com › how-do-i-validate-a-phone-number-using-regex-313cb1a44408
How do I Validate a Phone Number using Regex? | by The Tech Platform | Medium
January 4, 2024 - Run your ASP.NET application, and when you enter a phone number into the PhoneNumberTextBox and click the submit button, the RegularExpressionValidator will enforce the regex pattern.
🌐
regex101
regex101.com › library › cFEhad
regex101: US Phone number regex
Search string for use in contact cleaning project $1 = intenational code, omitting preceding "+" $2 = area code $3 = first three digits of phone number $4 = last four digits of phone $5 = extension, inclusive of any commas or hashes to automate ...
Find elsewhere
🌐
Trestle
trestleiq.com › home › product › phone validation regex: the what, how, and pros and cons
Phone Validation Regex: The What, How, and Pros and Cons
September 24, 2025 - For example, a simple check, like if the phone is 10 or 11 digits and only contains specific or special characters, is an easy way to check that the number provided is valid. Without a high degree of confidence, time and resources are wasted on chasing down leads or reaching out to individuals with bad data. This can be done using what we call regex ...
🌐
Stack Abuse
stackabuse.com › validate-phone-numbers-in-javascript-with-regular-expressions
Validate Phone Numbers in JavaScript with Regular Expressions
June 7, 2023 - The pattern is instantiated using the RegExp constructor and passing the expression as a parameter to the constructor. Then, we test the phone number using the test method available in the object. Using an if-else statement, we check if the phone number passes the test.
🌐
freeCodeCamp
forum.freecodecamp.org › javascript
US Phone Number Validation - Help Needed - JavaScript
July 26, 2020 - I got a regex from Stack Overflow for phone number validation, but it doesn’t get all of the tests to pass. The test results are: telephoneCheck("1 555-555-5555") should return true. telephoneCheck("1 (555) 555-5555") …
🌐
AbstractAPI
abstractapi.com › api guides, tips & tricks › 5 ways to validate phone numbers with regex
5 Ways to Validate Phone Numbers Using Regex
August 8, 2025 - Validating phone numbers with regular expressions is a common first step in ensuring data quality for user-facing applications. We will explore five ways to implement this validation using regex, complete with working code snippets.
🌐
Regex Tester
regextester.com › 98583
US phone number validate - Regex Tester/Debugger
Url checker with or without http:// or https:// Match string not containing string Check if a string only contains numbers Only letters and numbers Match elements of a url date format (yyyy-mm-dd) Url Validation Regex | Regular Expression - Taha Match an email address Validate an ip address nginx test Extract String Between Two STRINGS match whole word Match anything enclosed by square brackets. Match or Validate phone number Match html tag Find Substring within a string that begins and ends with paranthesis Blocking site with unblocked games Match dates (M/D/YY, M/D/YYY, MM/DD/YY, MM/DD/YYYY) Empty String Match if doesn't start with string
🌐
freeCodeCamp
forum.freecodecamp.org › javascript
Regex for US phone number - JavaScript
December 3, 2021 - Tell us what’s happening: Describe your issue in detail here. **Your code so far** function telephoneCheck(str) { return /^[\+]?([0-9][\s]?|[0-9]?)([(][0-9]{3}[)][\s]?|[0-9]{3}[-\s\.]?)[0-9]{3}[-\s\.]?[0-9]{4,6}$/ig.test(str); } telephoneCheck("555-555-5555"); **Your browser information:** User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.55 Safari/537.36 Challenge: Telephone Number Validator Link to the challenge...
🌐
regex101
regex101.com › library › XomD2x
regex101: US phone number
Open regex in editor · US phone number, try to catch as many as possible ·
🌐
Reddit
reddit.com › r/googleforms › help with regex validation for worldwide email, phone numbers and address
r/GoogleForms on Reddit: help with regex validation for worldwide email, phone numbers and address
July 31, 2024 -

Hello, posting here in case someone can help. I need to add some sort of data validation in google forms for international phone numbers, the rules I have are:

The numbers should start with a plus sign ( + )
It should be followed by Country code and National number 1 to 4 digits between 0 and 9
It may contain white spaces or a hyphen ( – ).
the length of phone numbers may vary from 7 digits to 15 digits.

The form is going to be available to people that are based worldwide so it needs to be flexible enough to cover most countries. I've searched online extensively as this is quite common but my phone numbers keep getting errors, anyone has one that works? Thank you

🌐
UI Bakery
uibakery.io › regex-library › phone-number
Phone number regex
var regex = /^\+?\d{1,4}?[-.\s]?\(?\d{1,3}?\)?[-.\s]?\d{1,4}[-.\s]?\d{1,4}[-.\s]?\d{1,9}$/; regex.test('+1 (615) 243-5172'); // returns true ... While validation of phone numbers using regex can give a possibility to check the format of the phone number, it does not guarantee that the number exists.
🌐
Codemia
codemia.io › knowledge-hub › path › how_to_validate_phone_numbers_using_regex
How to validate phone numbers using regex
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises
🌐
ASPSnippets
aspsnippets.com › Articles › 3767 › US-Mobile-Number-validation-using-JavaScript-and-Regular-Expression
US Mobile Number validation using JavaScript and Regular Expression
November 7, 2022 - explained with an example, how to implement US Mobile Number validation using Regular Expression (Regex) in JavaScript.