Search code examples
regexdrupal

How to define custom filter to block spam in Drupal


Drupal has a nice spam module with a lot of features, including defining Custom filters. The filters can be either Plain text or Regular expressions. I am a bit familiar with regexp but not sure how to define regexps in spam module in order to block any occurrences of spam strings like

myblablaviagra.com

or phone numbers like:

091234567

The thing that I am really not sure of is that whether the regex need to be enclosed in '/ /' or something else. Unfortunately I could not find any examples of custom regex filter in action, hence the question.


Solution

  • According to the docs, you can define a literal string that is matched "verbatim" using quotes 'myblablaviagra.com', or a regex using delimiters /^\d+$/ (standard Perl re syntax).