I need the regex to check if a string only contains numbers, letters, hyphens or underscore
$string1 = \"This is a string*\"; $string2 = \"this_is-a-string\"
if(!preg_match('/^[\w-]+$/', $string1)) { echo "String 1 not acceptable acceptable"; // String2 acceptable }