I am looking to build a regex for JavaScript.
~!@#$&*(),;:'-_
Other chars should fail.
I did try /[a-zA-Z0-9][\~\!\@\#\$*0\-_]/
It got failed for ^
Use a regexp that matches all the allowed characters, along with a lookahead that matches at least one of the required characters. The regexp needs to be anchored to match the entire input.
(?=.*[a-zA-Z0-9])^[a-zA-Z0-9~!@#$&*(),;:'\-_]*$