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\"
Why to use regex? PHP has some built in functionality to do that
preg_match('/\s/',$username) will check for blank space
preg_match('/\s/',$username)
!ctype_alnum(str_replace($valid_symbols, '', $string1)) will check for valid_symbols
!ctype_alnum(str_replace($valid_symbols, '', $string1))