regex for phone number
match a phone number
^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$
Regex Flags
global match
?
ignore case
?
multiline
?
dotAll
?
unicode
?
sticky
?
Match a phone number with "-" and/or country code.
This is a generalized expression which works most of the time. There are too many variables to make this work around the world. Do try with the phone numbers in your country before using.
Cheatsheet
| expr | usage |
|---|---|
/[0-9]/ | matches all digits |
/(hello){1,3}/ | matches "hello" that occur between 1 and 3 times (inclusive) |
/^/ | matches beginning of a line |
/$/ | matches end of a line |
iHateRegex
by
geon