Might be easier if you specify what you want to allow.
For example, to allow only one or more alphanumeric characters and the dash, in the C locale, using PCRE syntax with a string $str:
preg_match('/[a-z0-9-]/i', $str);
or
preg_match('/[\w\d-]/', $str);
where returning false (or rather 0) would mean that $str should be accepted.