开发者

How to avoid spam using bad words by duplicate characters?

开发者 https://www.devze.com 2023-03-22 00:47 出处:网络
As you know, there is a common code to replace bad words: $badwords = array(\'bad\', \'very bad\'); $string = str_replace($badwords, \"***\", $string)开发者_运维问答;

As you know, there is a common code to replace bad words:

$badwords = array('bad', 'very bad');
$string = str_replace($badwords, "***", $string)开发者_运维问答;

But what if spammers duplicate some of characters? like "baaad" or "veery bad".


You could implement a Levenshtein Distance algorithm using PHP's levenshtein. If the word only needs one edit to become a bad word, then it could be a possible spam word with duplicate characters.

0

精彩评论

暂无评论...
验证码 换一张
取 消