Possible Duplicate:
regular expression for letters, numbers and - _
I would like to return true if the $var only includes (A-Z, a-z, 0-9 and -)
Something like: (this preg_match is to check if $var is mail, but I need the above)
if (!preg_match("/^[-!#$%&\'*+\\.\/0-9=?A-Z^_`{|}~]+@([-0-9A-Z]+\.)+([0-9A-Z]){2,4}$/i", $var))
return false;
return true;
Any ideas? Im new with preg_match.