^(\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4}$

Matches the following

123-456-7890
(123) 456-7890
123 456 7890
123.456.7890
+91 (123) 456-7890

If you do not want a match on non-US numbers use

^(\+0?1\s)?\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4}$

Update :
As noticed by user Simon Weaver below, if you are also interested in matching on unformatted numbers just make the separator character class optional as [\s.-]?

^(\+\d{1,2}\s?)?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$

https://regex101.com/r/j48BZs/2

Answer from Ravi K Thapliyal on Stack Overflow
Top answer
1 of 16
408
^(\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4}$

Matches the following

123-456-7890
(123) 456-7890
123 456 7890
123.456.7890
+91 (123) 456-7890

If you do not want a match on non-US numbers use

^(\+0?1\s)?\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4}$

Update :
As noticed by user Simon Weaver below, if you are also interested in matching on unformatted numbers just make the separator character class optional as [\s.-]?

^(\+\d{1,2}\s?)?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$

https://regex101.com/r/j48BZs/2

2 of 16
247

There are many variations possible for this problem. Here is a regular expression similar to an answer I previously placed on SO.

^\s*(?:\+?(\d{1,3}))?[-. (]*(\d{3})[-. )]*(\d{3})[-. ]*(\d{4})(?: *x(\d+))?\s*$

It would match the following examples and much more:

18005551234
1 800 555 1234
+1 800 555-1234
+86 800 555 1234
1-800-555-1234
1 (800) 555-1234
(800)555-1234
(800) 555-1234
(800)5551234
800-555-1234
800.555.1234
800 555 1234x5678
8005551234 x5678
1    800    555-1234
1----800----555-1234

Regardless of the way the phone number is entered, the capture groups can be used to breakdown the phone number so you can process it in your code.

  • Group1: Country Code (ex: 1 or 86)
  • Group2: Area Code (ex: 800)
  • Group3: Exchange (ex: 555)
  • Group4: Subscriber Number (ex: 1234)
  • Group5: Extension (ex: 5678)

Here is a breakdown of the expression if you're interested:

^\s*                #Line start, match any whitespaces at the beginning if any.
(?:\+?(\d{1,3}))?   #GROUP 1: The country code. Optional.
[-. (]*             #Allow certain non numeric characters that may appear between the Country Code and the Area Code.
(\d{3})             #GROUP 2: The Area Code. Required.
[-. )]*             #Allow certain non numeric characters that may appear between the Area Code and the Exchange number.
(\d{3})             #GROUP 3: The Exchange number. Required.
[-. ]*              #Allow certain non numeric characters that may appear between the Exchange number and the Subscriber number.
(\d{4})             #Group 4: The Subscriber Number. Required.
(?: *x(\d+))?       #Group 5: The Extension number. Optional.
\s*$                #Match any ending whitespaces if any and the end of string.

To make the Area Code optional, just add a question mark after the (\d{3}) for the area code.

🌐
Reddit
reddit.com › r/regex › extracting 10 digits from phone numbers
r/regex on Reddit: Extracting 10 digits from phone numbers
January 8, 2025 -

I'm completely new to regular expressions as of this morning.

I'm trying to trim phone numbers to their 10 digit numbers, removing the 1 and +1 variants in my data. I've figured out that I can use (.{10}$) to get the last 10 numbers of a phone number. The problem seems that it's removing the 10 digits and leaving what's left, 1 and +1. I've told it to use $1 but no luck. Can someone help?

Discussions

Get valid phone numbers using Regex
Hi I have a requirement where I want to fetch only valid phone numbers from India…how can I do this using Regex? More on forum.uipath.com
🌐 forum.uipath.com
7
0
February 3, 2025
How to make sure my Phone Number field has 10 digits??
This is a text field, and it accepts ... all 10 digits of the phone number. Previously I tried to make the field required but it ended up breaking the template of the issues we receive via email (only Description and Summary can be required). Any way I can validate the field upon issue create using regex... More on community.atlassian.com
🌐 community.atlassian.com
January 13, 2023
Extracting 10 digits from phone numbers
How do your input strings look like? If you just want to remove everything except for the last 10 characters, you can replace ^.*(?=.{10}$) with nothing, or replace ^.*(.{10})$ with $1. This doesn't work with punctuation or whitespace or anything else inside the digits. You can use \d or [0-9] instead of "." to make sure you actually match digits on the right hand side. More on reddit.com
🌐 r/regex
8
2
January 8, 2025
Match a 10 digit number that doesn't start with certain numbers

Something like this should work for you.

416\d{7}|(\d{10})

Group #1 will contain the strings you want. Will test this when I get to my computer.

More on reddit.com
🌐 r/regex
12
3
May 7, 2019
🌐
RegExr
regexr.com › 3aa8n
10 digit phone no
Full RegEx Reference with help & examples.
🌐
regex101
regex101.com › library › gB4nY1
regex101: 10-digit phone number with hyphens
Viet Nam Phone Number Regex. This regex include: Cellphone number: Viettel, Vinaphone, Mobiphone, Vietnamobile, Iteltelecom, Reddi (055) Telephone number (such as: 024, 028,...) Start with 0 or 84 Exactly 10 or 11 numbersSubmitted by tuangt12
🌐
Squash
squash.io › how-to-match-standard-10-digit-phone-number-with-regex
How To Match Standard 10 Digit Phone Numbers With Regex
These patterns or functions are often more comprehensive and handle various phone number formats and edge cases. For example, in JavaScript, you can use the pattern attribute with the value "[0-9]{10}" in an HTML input element to enforce a 10-digit ...
🌐
regex101
regex101.com › library › cG4kD9
regex101: 10-digit number
Mobile Networks: (Vodafone: 10, e&:11, Orange:12, we:15) Operator Code: The phone number must be followed by one of the valid operator prefixes (10, 11, 12, or 15), corresponding to major mobile networks in Egypt. Number Length: The phone number must have exactly 8 digits following the operator code, for a total of 11 digits (including the country code and operator code). This regex is commonly used to ensure that the input phone numbers follow the standard Egyptian format and belong to the correct mobile operators.Submitted by Mohamed Amir
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 ...
🌐
Medium
medium.com › @abhishekmailservices › validating-indian-phone-numbers-using-regular-expressions-regex-db4670bbc5d5
Validating Indian Phone Numbers Using Regular Expressions (Regex) | by Abhishek K | Medium
September 25, 2024 - [0]?(91)?: This checks for an optional leading 0 or 91 (without the +) before the phone number. [6789]: Ensures the first digit of the number is between 6 and 9. \d{9}: This ensures exactly 9 more digits follow, making the total length of the ...
🌐
Qodex
qodex.ai › home › all tools › getting started › phone number regex javascript validator
Phone Number Regex JavaScript Validator — Test Patterns
Count the Digits: Once you have a string of pure digits, check if its length fits your desired range. For example, the US and Canada typically expect 10-digit numbers for local calls, while countries like India may have 10 or 11 digits with ...
Rating: 4.9 ​ - ​ 60 votes
Top answer
1 of 2
1
Hi Vinay, ·   · Please find the snippet below, wrote the code in view of US mobile phone number validation · var phoneNum = "+14445551234" · phoneNum = phoneNum.replace(/ /g, ""); //Remove all spaces from phone number · var validUSPhoneExp = /^((\+1 ?)?((\(\d{3}\))|(\d{3}) ?\-) ?(\d{3}) *\- *\d{4})|((\+1 ?)?)\d{10}$/; · var phoneNumWithoutDelimeters = phoneNum.replace(/( |\(|\)|\-)/g,""); · var invalidPattern1 = /^(\+1)?(1{10}|2{10}|3{10}|4{10}|5{10}|6{10}|7{10}|8{10}|9{10}|0{10})$/; //Phone number with same digits · var invalidPattern2 = /^(\+1)?(\d{3}(555)\d{4})$/; // US mobile numbers used in movies or TV have 555 in the 4th 5th and 6th digits of the phone numbers. Treating these as invalid. · var result = validUSPhoneExp.test(phoneNum) && !invalidPattern1.test(phoneNumWithoutDelimeters) && !invalidPattern2.test(phoneNumWithoutDelimeters); · var finalNum = ""; · if(result == true) { · // phoneNum varible has correct phone number available. · } · Above code validates for below formats returns true in the result with some exceptions noted below these formats.(xxx)xxx-xxx+1(xxx)xxx-xxx(xxx) xxx-xxx(xxx) xxx -xxxxxx-xxx-xxxxxx - xxx - xxxxxx -xxx -xxx+1xxx -xxx -xxx+1xxxxxxxxxx · But if the mobile numbers have 555 in the 6,7,8 digits, they are used in movies in US and they are not allocated to anyone. Above code treats them as invalid phone numbers.If the US mobile phone or 10 digit mobile number has same number in all the places they are treated as invalid numbers.For example, all the numbers below are treated as invalid.+11111111111+1(111)111-1111+1111-111-1111+1 111-111-1111+11115551234+1111-555-1234 · Thanks and regards, · Subrahmanyam Satti
2 of 2
0
var number = g_form.getValue('field_name'); · var check = /^[0-9]{10}/; · var result = number.match(check); · if(result==true) · { g_form.setValue('field_name', 'number'); } · else · { alert("Dear Requestor, please make sure that the number you provide is 10 digits long"); } ·   · please mark helpful /correct based on impact · Regards, · Aniket S
🌐
C# Corner
c-sharpcorner.com › blogs › validate-mobile-number-with-10-digits-in-asp-net
Validate Mobile Number With 10 Digits In ASP.NET
August 18, 2019 - Using a Regular Expression, we can validate a TextBox with 10 digit mobile number in C#.
🌐
Mendix
community.mendix.com › link › spaces › academy › questions › 123390
Regex of Phone number? | Mendix Forum
March 24, 2023 - The Mendix Forum is the place where you can connect with Makers like you, get answers to your questions and post ideas for our product managers.
🌐
Atlassian Community
community.atlassian.com › q&a › jira › questions › how to make sure my phone number field has 10 digits??
How to make sure my Phone Number field has 10 digits??
January 13, 2023 - A regex validator on the create transition of your workflow is basically the out-of-the-box way you could set this up. This KB article has a good description of your use case. It even refers to a phone number custom field as an example on how to set it up.