I am searching for a regular expression for allowing alphanumeric characters, -, _ or spaces in JavaScript/jQuery. I tried Googling but wasn\'t able to find that.
Ca
/^[-\w\s]+$/
\w matches letters, digits, and underscores
\s matches spaces, tabs, and line breaks
- matches the hyphen (if you have hyphen in your character set example [a-z], be sure to place the hyphen at the beginning like so [-a-z])