Print Page | Close Window

RegEx for scrambled words

Printed From: LogSat Software
Category: Spam Filter ISP
Forum Name: Spam Filter ISP Support
Forum Description: General support for Spam Filter ISP
URL: https://www.logsat.com/spamfilter/forums/forum_posts.asp?TID=5129
Printed Date: 04 November 2025 at 8:49am


Topic: RegEx for scrambled words
Posted By: mikek
Subject: RegEx for scrambled words
Date Posted: 13 April 2005 at 9:20am

I'm looking for an effective regex to match scrambled words such as:

sotfware
stofware
sofwtare

and so on, but not matching the real word (software).

All I've come up with so far is

((?i)(s[oftwa]{5}re))

but that, will, of course, match "software" as well.

Any ideas?




Replies:
Posted By: lead
Date Posted: 14 April 2005 at 10:10am
I can't think of a fix in just one RegEx but you could use a combination of RegEx

((?i)(sf[otwa]{4}re))
((?i)(st[ofwa]{4}re))
((?i)(sw[ofta]{4}re))
((?i)(sa[oftw]{4}re))

which target the scrambled words.
Would this work?




Posted By: mikek
Date Posted: 14 April 2005 at 12:01pm
that's what I'm doing now, but for 5 characters, there are a lot of combinations.... I thought it could be done easier...


Posted By: Desperado
Date Posted: 14 April 2005 at 12:31pm

Dan,

With the existing implementation of RegEX, I am not sure this can be simplified.  With the standard Perl RegEx, I would use a "NOT" function but that requires "Look Ahead" which I am nearly certain is *not* supported.

Regards,



-------------
The Desperado
Dan Seligmann.
Work: http://www.mags.net
Personal: http://www.desperado.com




Print Page | Close Window