Currently I have this regular expression to validate letters, dash and spaces.
/^[a-zA-Z-\s]*$/
Now, I am quite confused how can this be rewritten to have a rule that it will accept everything except numbers?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To have anything except something, you need a negated character class
A character class that starts with
^is a negated class,\dis a predefined class that contains digits.If you have really only digits you can shorten this further, there is also a predefined negation of
\dthat is\DSo
[^\d]=\DYou may find this link to a regex reference on regular-expressions.info useful