I've been trying to find a validation regex to do some loose validation on phone numbers. I'm going to strip some of the stuff out when I use them, but I would like to allow the user the freedom to enter their number as they want, and I want to display it as they have entered it.
I figured that the best thing to do is whitelist my characters. I figured on
[space] + - [0-9] ( )
Are there any other characters that I should be allowing? I'm not quite sure if I should be looking for characters which do not match this in the pattern?
So far all I can come up with is,
[\+0-9\s\-\(\)]
Which seems to match every character
I've been playing around in here, http://gskinner.com/RegExr/
Using this as my data,
+44 787 553 7794
+1-818-923-4821
&9_981-432 p
+44 (0) 20 874 1932
If anyone could nudge me in the right direction, I'd really appreciate it! Thanks :)