This question already has an answer here:
I have searched within SO and found out several regular expressions to be used to include ONLY THESE a-z A-Z 0-9 - _
. So far what I have tried was this one, /[^a-zA-Z0-9_ %\[\]\.\(\)%&-]/s
. What this actually did was it did not exclude brackets {} []
and parenthesis ()
. I am not very experienced with regex
, heck I don't fully fathom the whole meaning, structure/format of it so can somebody provide me the exact regex
which I am looking for? Thanks for the time.
</div>
Here it is :
^[a-zA-Z0-9_-]{1,}$
Will check Any word of at least one letter, number , _ or -
Here is the tutorial for basic REGEX.
This should do the trick
/^[\w\-]+$/