Add white space to regular expression
I have these two regular expressions:
At the moment, if the user enters a space e.g. 22 22 22222, then it returns as invalid because the regular expressions don't accept any white space.
I would like the user to be able to enter white spaces as well as not entering white space and the number being returned as valid.
e.g. 22 22 22222 and 222222222
Please can someone help me amend the above regular expressions so that they also allow the user to enter both white space and no white space?
Thank you very much
As I've said to many people, for phone numbers it's a lot easier if you strip out invalid symbols and validate the rest. Specifically, remove all non-digits and check what remains. Then reformat it into whatever shape you want.
the regular expressions i posted above only accept numbers and nothing esle. however, i wanted to change it so that they accept white space as well.
do you know how i can amend them to do this?
Change the \d into a character set ([0-9] or [\d]) and add a space to all the character sets.
What about hyphens? I enter phone numbers using hyphens.