PHP - preg_match - How to match a string upper/lower case with anything before or after it?

php, preg-match

Solution

How's this:

if (preg_match("/<script\b[^>]*>/i",$userInput))
{
    $bannedWord = 'script';
    logHax();
    return TRUE;
}

Problem

I have a part of a function that goes like this: ``` if (preg_match("#\bscript\b#",$userInput)) { $bannedWord = 'script'; logHax(); return TRUE; } ``` This is causing a problem for what I am trying to accomplish because it will only match the exact word "script" and not variations of it, like "ScriPt" or "`<script>`". What I would like to have is the examples of the not matched strings along with the original string return true.

Original source