I have this regex expression var re = /(?:\d{3}|\(\d{3}\))([\w-\/\.]?)\d{3}\1\d{4}/;, however, the \w whitespace doesn't work on this test console.log(re.test('123 456 7890'));
Here is my jsfiddle: http://jsfiddle.net/Bqb22/
I have this regex expression var re = /(?:\d{3}|\(\d{3}\))([\w-\/\.]?)\d{3}\1\d{4}/;, however, the \w whitespace doesn't work on this test console.log(re.test('123 456 7890'));
Here is my jsfiddle: http://jsfiddle.net/Bqb22/
You shouldn't use \w for whitespace. Use \s instead. (\w is word character, the same as [0-9A-Za-z_], and should not be used to indicate whitespace).