views:

113

answers:

2

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?

+3  A: 
if(preg_match("~[bcdfghjklmnpqrstvwxyz]{4,}~", $string)......
stereofrog
I would add an `i` after the pattern to make it case-insensitive.
Ben James
+8  A: 

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

jensgram
dammit - too late :)
jensgram
But more correct. The question was about "more than 5" though, so it should be `{6}`. For example, there is a slovak word with 5 consonants in a row "zmrzlina". :)
Lukáš Lalinský
@Lukáš Lalinský - you're right. Edited my answer.
jensgram