CodeIgniter 2禁止关键字符

时间:2016-01-15 19:51:32

标签: regex

system\core\Input.php

if(!preg_match('/^[~a-zA-Z0-9{},:_\/-]+$/i', $str))
{

    exit('Disallowed Key Characters: '.$str);
}

这会触发不允许的关键字符:$str包含:

{"education_level":"1","job_experience":"1","occupation":"41-3011","onet_code"
:"41-3011_00","region":"22220","relevance":"0","school":"0","schoolstate":"0","state":"4","gpa":"0","major"
:"0"}

1 个答案:

答案 0 :(得分:0)

您还应该允许引号字符(")和空格(\s)。你的正则表达式应该是:

/^[~a-zA-Z0-9{},:_\/"\s-]+$/i

Regex101 demo