[thelist] Reg Ex - everything except a phrase

Joshua Olson joshua at waetech.com
Fri Sep 12 08:20:25 CDT 2003


----- Original Message ----- 
From: "Mark M" <mark.m at optushome.com.au>
Sent: Friday, September 12, 2003 2:52 AM


> > I tested the snippet using Python 2.3 on a Win2K box and it works
> > fine ("Hello Fred" does not match) on this combination. It would be
> > terrible if word boundary matching behaviour did vary from platform
> > to platform. I will check the regex on Python 2.2 on my Linux box at
home
> > and see what gives.
>
> Hate to pipe in at this point (considering I started this thread)
>
> - Pity I'm using ColdFusion MX to do my RegExs...
>
> Still - interesting conversation never the less.

Mark,

Forward Negative lookaheads don't work.  Have you tried the first solution I
offered?

Something along the lines of:

(.{1,3}|.{5,}|f[^r].{2}|fr[^e].{1}|fre[^d]{1}|[^f].{3})

One thing I don't think you've mentioned yet (and this is *really*
important) is where this regex will be used.  Will it be used as part of a
larger regex or will it be stand alone?

If it's stand alone you could simply use NOT Find(substring, string).

Or, if you need it to only include full words:

<cfset regex = "(^|[^a-z0-9])fred([^a-z0-9]|$)">

NOT ReFind(regex, string)

If you need to include the regex as part of a larger regex then the solution
will change drastically and you cannot use neither a simple Find nor the NOT
ReFind presented above.  I may be able to come up with something, but so far
my original idea is the only one that I've found that works in CF.

HTH,

<><><><><><><><><><>
Joshua Olson
Web Application Engineer
WAE Tech Inc.
http://www.waetech.com
706.210.0168



More information about the thelist mailing list