【发布时间】:2011-10-13 13:40:38
【问题描述】:
我有一个包含被屏蔽词列表的表格
+--------+------------------+
| id | word |
+--------+------------------+
| 1 | this |
| 2 | word |
| 3 | is |
| 4 | blocked |
+--------+------------------+
我需要做的是编写一个函数来检查一个字符串是否包含一个阻塞的单词(表中的单词),例如:
function blocked($string){
if(***blocked***){
return true;
}else{
return false;
}
}
该函数应该返回true,无论该单词是单独的单词,还是隐藏在另一个单词中:
$string = "I want to see if this string is blocked"; //returns `true` because it contains 'this', 'is' and 'blocked'
$string = "iwanttoseeifthisstringisblocked"; //returns `true`
希望我的问题很清楚,
任何帮助表示赞赏
【问题讨论】:
-
从表格或 google Boyer-Moore 构造一个高效的正则表达式