开发者

php how to check a string for more than 5 consonants in a row

As a spam filter I want to block any comments that contain

djgalkgjlkdg

or any other excessive amount of consonants in a row.

I thought of maybe having an array of consonants and then check the comment with it, but seems too long and cumber开发者_JS百科some.

Do you know of any way I can do this without guzzling memory?


preg_match('/[bcdfghjklmnpqrstvwxz]{6}/i', $input) perhaps?


if(preg_match("~[bcdfghjklmnpqrstvwxyz]{4,}~", $string)......


Matches any alphabetic character but numbers:

/i at the end makes it case insensitive.

$find = '/([b-df-hj-np-tv-z]{4})/i';
if(preg_match($find,$comment)){
   //spam filter action
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜