regex - My regular expression allows spaces when formatting phone number -
I have the following Regex used in javascript.
phone_number.match (/ ^ 1- \ d {3} - \ d {3} - \ d {4} $ /);
It works great with one exception. This allows spaces.
I want to format strictly 1-xxx-xxx-xxxx
but this 1-xxx-xxx-xxxx Allows
Anyone have any idea how can I not allow spaces?
No, this is not ;-) It's just impossible to get your regexp / ^ 1- You do not have any space character in \ d {3} - \ d {3} - \ d {4} $ /
- and it does not match (check).
Comments
Post a Comment