I need to validate user input. Users are allowed to use all characters, digits, "_" and "-".
Currently, I am using the following code snippet to validate:
myString.search(/\W/) != -1
It successfully validates everything I need except for the hyphen "-". How can I modify the code to allow for any non-word character except for the hyphen?