Could anyone tell me what RegEx would work to validate an international phone number including white space between the numbers and also allowing for these chars: - ( )
See A comprehensive regex for phone number validation
/^
[\s]
or \s
[(]
and [)]
. Using \(
and \)
is ugly and can make things confusing.?
after it -
or [-]
. If you do not put it first or last in a series of other characters, though, you may need to escape it: \-
[-.\s]
will require a hyphen, period, or space. A question mark after the last bracket will make all of those optional for that slot. \d{3}
: Requires a 3-digit number: 000-999. Shorthand for
[0-9][0-9][0-9]
. [2-9]
: Requires a digit 2-9 for that slot.(\+|1\s)?
: Accept a "plus" or a 1 and a space (pipe character, |
, is "or"), and make it optional. The "plus" sign must be escaped.[246]
will require a 2, 4, or 6. [77|78]
will require 77 or 78.$/
: End the expression