PHP-preg_match-如何将字符串的大写/小写与之前或之后的内容进行匹配? [英] PHP - preg_match - How to match a string upper/lower case with anything before or after it?
本文介绍了PHP-preg_match-如何将字符串的大写/小写与之前或之后的内容进行匹配?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一部分函数是这样的:
I have a part of a function that goes like this:
if (preg_match("#\bscript\b#",$userInput))
{
$bannedWord = 'script';
logHax();
return TRUE;
}
这给我要完成的工作造成了问题,因为它只会匹配确切的单词"script",而不会匹配它的变体,例如"ScriPt"或"<script>
".
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>
".
我想要的是不匹配的字符串以及原始字符串返回true的示例.
What I would like to have is the examples of the not matched strings along with the original string return true.
有人可以让我对这件事有一些了解.
Could someone provide me with a bit of understanding on this matter.
也将不胜感激任何涵盖此类内容的教程,
Also any tutorials that cover something like this would be greatly appreciated,
谢谢!
推荐答案
这是怎么回事:
if (preg_match("/<script\b[^>]*>/i",$userInput))
{
$bannedWord = 'script';
logHax();
return TRUE;
}
这篇关于PHP-preg_match-如何将字符串的大写/小写与之前或之后的内容进行匹配?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文