我在php中使用此代码来检测字符串是否包含az,AZ,0-9以外的字符.我想检查字符串是否包含任何空格.我应该在模式中添加什么?
if (preg_match ('/[^a-zA-Z0-9]/i', $getmail)) {
// The string contains characters other than a-z and A-Z and 0-9
}
Run Code Online (Sandbox Code Playgroud)
如果要为当前模式添加空间,实际上需要在模式中输入空格:
/[^a-z0-9 ]/i
^
Notice the space there
Run Code Online (Sandbox Code Playgroud)