The Dopefly Tech Blog

<< The Dopefly Tech Blog Main page

The Viagra Expression

posted under category: ColdFusion on December 2, 2004 at 1:00 am by MrNate

Rob Cockerham of has inspired me. After reading his report on Viagra spam, titled There Are 600,426,974,379,824,381,952 Ways To Spell Viagra, I realized that I needed to develop a regular expression that can handle every misspelling possible. Well, it looks like I'm getting close.

Here is the RegEx so far:


It's been tested with ColdFusion and Java, and should be similar to Perl syntax. It's about 260 characters long so far, test it out for yourself. It's not perfect, but it does a darn good job!

1) Sorry to fullasagoog for throwing off your formatting
2) I made a page to test the viagra expression

Too old to comment!
On Dec 2, 2004 at 1:00 AM Pete Freitag ( said:
You should put up a page where we can test it.

On Dec 2, 2004 at 1:00 AM Nathan Strutz ( said:
Thanks Pete, I just updated the blog entry. I'll get it up soon.

On Dec 4, 2004 at 1:00 AM Bjorn (bjorn who can't believe it's not said:

Close...very close..but these common variations on everyone's favourite 'hardener' still 'slip' through...

v1@gr@, v1agr@, viagr@, vi@gr@

On Jun 24, 2005 at 1:00 AM Brian Scot ( said:
Thanks, nice regex, but the word boundry, \b, at the begenning and end of the expression allows variations beginning with \/ or ending with @ to pass. These are not considered words and the boundry is actually inside these characters. Taking them off catches more variations, but also catches variations with extra beginning or trailing letters. Which come to think of it may be better in my opinion.

On Jun 27, 2006 at 1:00 AM jakarikukan (tyut from said: | filmy darmowe nowe | [URL=]darmowe krotkie filmy najlepsze[/URL] |

On Jul 23, 2006 at 1:00 AM Chimmy ( said:
This RegEx will find the following valid strings as well as the "Viagra" strings:

On Aug 1, 2006 at 1:00 AM Den ( said:
The "i" variants should also include the "inverted exclamation mark", usually used in Spanish etc. languages, since it looks like an "i" and can be used instead of it: ¡

On Dec 7, 2006 at 1:00 AM Bill Knight (william.j.knight, by way of said:
You might also want to include ^ as a varient for A, as

is not caught.

On Jan 15, 2007 at 1:00 AM Mark ( who would have preferred an address at said:
the text is not at the site anymore (millions of ways of writing viagra), but google cache has it

On Jun 4, 2009 at 1:00 AM jblo (jbull0ck whose domain rhymes with said:
catches vagina
Too old to comment!