Wednesday, 18 September 2013

Including Capital & Non Capital Letters in Regex

Including Capital & Non Capital Letters in Regex

I'm attempting to create an SQL filtering system which notifies the user
when the request contains any of the included words.
Currently my regex only supports all caps & I was wondering whether it
would be possible to have it also accept non-caps as-well as other
combinations of letters for example SElEcT
I understand entering this manually would be possible, however, this is
not the most productive way to perform such a task.
This is my current code:
function checkString($string)
{
if(preg_match('[SELECT|FROM|DATABASE|TABLE|DROP|ALTER|LIKE|IN|BETWEEN|UNION|NULL|CHECK|JOIN|AVG|SUM|COUNT|FIRST|LAST|MAX|MIN|GROUP]',
$string
Thanks.

No comments:

Post a Comment