0
我已经使用php preg_replace
函数只允许来自变量字符串的字母数字字符。代码如下。此代码工作正常。允许一些特殊字符和字母数字字符
但现在我想允许一些特殊字符,如[email protected]#$%^&*()_+/
等与字母数字字符一起。这个怎么做?
$hashh=$_GET['hash'];
$hash = preg_replace("/[^a-zA-Z0-9]+/", "", $hashh);
我可以用这个还的preg_match? – John
当然''''开头的'^'意思是'Not'因此对于'preg_match',你可以将其删除,它将作为'/ [a-zA-Z0-9〜! @!$%^&*()_ + \ /] + /' – AXAI
还可以,如果(!preg_match(“/ [^ a-zA-Z0-9〜!@#$%^&*()_ + \ /] + /“,$ cpass)) { $ error =”Not valid Password!“; $ code = 3; } – John