Question

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 cumbersome.

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

Was it helpful?

Solution

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

OTHER TIPS

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
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top