Writing a Regular Expression with Regulazy
The first tool we’ll need is Regulazy from Roy Osherove - available at Roy’s blog. Regulazy allows you to enter text that you want to filter on and then build a Regular Expression (Regex) by substituting the text that may change with matching characters.
For example, say you get a lot of spam with “Viagra is sold here for cheap" in the subject. Unfortunately, spammers are pretty smart, so they’ll mess up basic filters by adding numbers or symbols into the phrase. This fools the filter, but doesn’t fool you.
As an example, you may receive spam with the following subject lines based on the one listed above:
- V1@gra is sold here for ch3ap
- V!agra 1s sold h3r3 for cheap
- V!@gra sold here for cheap
There are a lot of variations on that simple structure. You could attempt to come up with each variation and type it into your spam filter, but as soon as the spammers change a single character that you don’t have a case for, your filter will need updating.
Instead of dreaming up variations, you can use regular expressions to help build a framework for filtering. Regulazy is the tool that will help you out.
In order to use Regulazy you’ll need to have the Microsoft .NET Framework 2.0 installed – available here.