Either I'm not doing something right, or Wordfilter simply doesn't support regular expressions. Any easy way we could make this work?

Comments

white_pawn’s picture

Well, I guess one easy way to do it would be to change line 355:

$pattern = '/'. preg_quote($word->words, '/') .'/i';

to

$pattern = '/'. $word->words.'/i';

Which would work great in my case. However, this means messing with the core, which is not very nice for many reasons, as we all know. It could be a basis for a future addon, though, if anyone's interested.

dunx’s picture

The project would be so much more powerful if it just allowed the entry of regular expressions without the need for the PCRE_UTF8 stuff (although I don't fully understand why that's required anyway).

Would resolve the issues raised against D7:
http://drupal.org/node/1176872
http://drupal.org/node/883940

You could also do away with the standalone feature entirely, tweak the code as noted above (not that I've tested that) and provide a few handy hints on the configuration page for users new to regex patterns. Would also suggest that the UI would need to change as the | would get confusing (see stringoverrides module for an example).

Upgrade would be easy as you can just add the necessary regex to the values stored as standalone (and fix those two issues above raised on D7, but also affecting D6).

My usage case is simply for a rude word filter in a forum and I'm coming from a phpbb background. I would want to replace the "FFFF" word and "FFFFer", "FFFFwit", etc. with something less prone to be noticed by work place filters! So "/[^ ]FFFF(.*)[ $]/i" to "feck\\1".

Also, don't sort alphabetically, but use weighting so we can better handle special cases like "Arsenal" and "Scunthorpe"!

+lots :) or is this a brand new module we're talking about?

mxh’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

Drupal 6 support ended on February 24th 2016. https://www.drupal.org/drupal-6-eol