A collection of useful Regular Expressions to parse, validate, and format phone numbers around the world.
For many of us, knowing how to work with regular expressions is a huge time saver. Regular expressions are powerful but can be easy to misuse or even get wrong.
If you aren’t careful when building regex patterns, you can waste a lot of time tracking down hard-to-find bugs.
That’s why I created this handy collection of regexes that are great for phone numbers.
Table Of Contents:
US (North American) Phone Numbers
A regular expression to format and validate US (North American) Phone Numbers:
- 1234567890
- 123-456-7890
- 123.456.7890
- 123 456 7890
- (123) 456 7890
/^\\(?([0-9]{3})\\)?[-.\\s]?([0-9]{3})[-.\\s]?([0-9]{4})$/
UK Phone Numbers
A regular expression to format and validate UK Phone Numbers, which should contain 11 digits and are normally in the format (01234) 123123.
- +447222555555
- +44 7222 555 555
- (0722) 5555555 #2222
/^(((\+44\s?\d{4}|\(?0\d{4}\)?)\s?\d{3}\s?\d{3})|((\+44\s?\d{3}|\(?0\d{3}\)?)\s?\d{3}\s?\d{4})|((\+44\s?\d{2}|\(?0\d{2}\)?)\s?\d{4}\s?\d{4}))(\s?\#(\d{4}|\d{3}))?$/
French Phone Numbers
A regular expression to format and validate French Phone Numbers.
- 0123456789
- 01 23 45 67 89
- 01.23.45.67.89
- 0123 45.67.89
- 0033 123-456-789
- +33-1.23.45.67.89
- +33 – 123 456 789
- +33(0) 123 456 789
- +33 (0)123 45 67 89
- +33 (0)1 2345-6789
- +33(0) – 123456789
/^(?:(?:\+|00)33[\s.-]{0,3}(?:\(0\)[\s.-]{0,3})?|0)[1-9](?:(?:[\s.-]?\d{2}){4}|\d{2}(?:[\s.-]?\d{3}){2})$/
German Phone Numbers
A regular expression to format and validate phone numbers in German format.
- (06442) 3933023
- (02852) 5996-0
- (042) 1818 87 9919
- 06442 / 3893023
- 06442 / 38 93 02 3
- 06442/3839023
- 042/ 88 17 890 0
- +49 221 549144 – 79
- +49 221 – 542194 79
- +49 (221) – 542944 79
- 0 52 22 – 9 50 93 10
- +49(0)121-79536 – 77
- +49(0)2221-39938-113
- +49 (0) 1739 906-44
- +49 (173) 1799 806-44
- 0214154914479
- 02141 54 91 44 79
- 01517953677
- +491517953677
- 015777953677
- 02162 – 54 91 44 79
- (02162) 54 91 44 79
/(\(?([\d \-\)\–\+\/\(]+){6,}\)?([ .\-–\/]?)([\d]+))/
Chinese Phone Numbers
A regular expression to format and validate telephone numbers in China.
- 0936-4211235
- 89076543
- 010-12345678-1234
/^(?:(?:\d{3}-)?\d{8}|^(?:\d{4}-)?\d{7,8})(?:-\d+)?$/
Chinese Mobile Phone Numbers
A regular expression to format and validate mobile telephone numbers in China.
- 008618311006933
- +8617888829981
- 19119255642
/^(?:(?:\+|00)86)?1(?:(?:3[\d])|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\d])|(?:9[189]))\d{8}$/
India Phone Numbers
A regular expression to format and validate India phone numbers and mobile numbers.
- 03595-259506
- 03592 245902
- 03598245785
- 9775876662
- 0 9754845789
- 0-9778545896
- +91 9456211568
- 91 9857842356
- 919578965389
/((\+*)((0[ -]*)*|((91 )*))((\d{12})+|(\d{10})+))|\d{5}([- ]*)\d{6}/
Brazilian Phone Numbers
A regular expression to format and validate Brazilian phone numbers.
- (12) 123 1234
- (01512) 123 1234
- (0xx12) 1234 1234
/\(([0-9]{2}|0{1}((x|[0-9]){2}[0-9]{2}))\)\s*[0-9]{3,4}[- ]*[0-9]{4}/
Australian Phone Numbers
A regular expression to format and validate Australian phone numbers.
- 0732105432
- 1300333444
- 131313
/(^1300\d{6}$)|(^1800|1900|1902\d{6}$)|(^0[2|3|7|8]{1}[0-9]{8}$)|(^13\d{4}$)|(^04\d{2,3}\d{6}$)/
Dutch Phone Numbers
A regular expression to format and validate Dutch phone numbers.
- +31235256677
- +31(0)235256677
- 023-5256677
/(^\+[0-9]{2}|^\+[0-9]{2}\(0\)|^\(\+[0-9]{2}\)\(0\)|^00[0-9]{2}|^0)([0-9]{9}$|[0-9\-\s]{10}$)/
Sweden Phone Numbers
A regular expression to format and validate Sweden phone numbers.
- +46 8 123 456 78
- 08-123 456 78
- 0123-456 78
/^(([+]\d{2}[ ][1-9]\d{0,2}[ ])|([0]\d{1,3}[-]))((\d{2}([ ]\d{2}){2})|(\d{3}([ ]\d{3})*([ ]\d{2})+))$/
Conclusion:
If you find that you need to parse, validate, or format phone numbers, the regular expressions found in this post will be a great help.
Just remember that international phone numbers can vary widely, and without context it can be difficult to determine which country codes are used or how to arrange these digits into a specific format.
The best solution for you is likely to check the source of the number to ensure its validity, although these regular expressions can still be useful if no such information is available.
Did you find any use for these regular expressions? Do you have any other regex to share with the rest of the community? What’s your best regex to validate phone numbers?
Please leave a comment below and let us know! It would be great to see what others are using as well.