我有以下功能
public function alpha_custom($str) {
return (! preg_match("/^([-a-z0-9_-])+$/i", $str)) ? FALSE : TRUE;
}
因此,如果字符串包含除字母数字字符,下划线或短划线以外的任何内容,则它将返回false。
现在我要添加以下内容:
SPACE
&
(
和)
.
(期间)请帮帮我。 谢谢。
答案 0 :(得分:0)
return (preg_match('/[^a-z_\(\)\.\&\ \-0-9]/i', $str)) ? FALSE : TRUE;
修改强> 我用它来检查它对我有用
function alpha_custom($str)
{
return (preg_match('/[^a-z_\(\)\.\&\ \-0-9]/i', $str)) ? 'FALSE' : 'TRUE';
}
echo alpha_custom('ravi._ &');