Issue
I have a input with name="exam[A+]". I have figured out that when I called $this->input->post("exam")
it is giving me an error called "Disallowed Key Characters". I want to add + sign in my key characters. Here is the code in the system file.
function _clean_input_keys($str)
{
if ( ! preg_match("/^[a-z0-9:_\/-]+$/i", $str))
{
exit('Disallowed Key Characters.');
}
// Clean UTF-8 if supported
if (UTF8_ENABLED === TRUE)
{
$str = $this->uni->clean_string($str);
}
return $str;
}
How do I change the regular expression to add the + sign in the input?
Solution
Use this regex to allow +
:
^[a-z0-9:_\/+-]+$
The main point is that the unescaped hyphen must be at the end of the character class.
Here is a demo.
Answered By - Wiktor Stribiżew
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.