Or you could have the bad words stored in a db, then you can easily add to
them......

<!--- Set variables to hold the title and bodytext --->

<cfset bodytext = " " & Form.reply_body & " ">

 <!--- Pull out all the bad words from the database --->

<cfquery name="getprofanities" datasource="#APPLICATION.chatdsn#">
        SELECT ID, badword, rate1
        FROM tbl_profanity
</cfquery>

<!--- Loop over the profanity list and compare with words in the
bodytext --->

<cfloop query="getprofanities">

        <cfset bodytext = ReplaceNoCase(bodytext," #getprofanities.badword# "," " &
RepeatString("*",Len(getprofanities.badword)) & " ","ALL")>

</cfloop>

HTH

Will

-----Original Message-----
From: Bryan Love [mailto:[EMAIL PROTECTED]]
Sent: 23 August 2001 17:40
To: CF-Talk
Subject: RE: regexp for swear filter


don't waste your time with regular expressions; in this case you already
know what you want to replace and regular expressions are for times when you
don't know exactly what your searching for.  Use replaceList(), like this:

badList = "apple,banana,car";
goodList = "*****,******,***";

text = "this banana drove the car into the apple at high speed. The apple
was upset."

listReplace(lcase(text),badList,goodList);

result = "this ****** drove the *** into the **** at high speed, The ****
was upset."


Bryan Love ACP
Internet Application Developer
Telecommunication Systems Inc.
[EMAIL PROTECTED]



-----Original Message-----
From: Rich Wild [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 23, 2001 2:54 AM
To: CF-Talk
Subject: regexp for swear filter


Dudes and laydeez,

Would anyone perchance know how to create a regexp to replace instances of
specific list items in a block of text, with their asterisked counterparts
(of the same length)?

What I mean by this:

list = "apple|banana|car"

text = "this banana drove the car into the apple at high speed. The apple
was upset."

result = "this ****** drove the *** into the **** at high speed, The ****
was upset."

I want to be able to do this with a single regexp, rather than list looping
over the text and replacing the index of the current loop iteration with its
repeatstring('*', len(index)) counterpart - which is slow if I have to do
this for many text blocks on the same page..

would the following work (bearing in mind I'm not great at regexps)?

rereplacenocase(thistext, "#list#", "#rereplace(list, '[^\|]', '*',
'ALL')#", "ALL")

hmmm even I'm not sure about that.

-------------------------------------------------------
Rich Wild
Senior Web Developer

-------------------------------------------------------
e-mango.com ltd                      Tel: 01202 587 400
Lansdowne Place                      Fax: 01202 587 401
17 Holdenhurst Road
Bournemouth                   Mailto:[EMAIL PROTECTED]
BH8 8EW, UK                      http://www.e-mango.com
-------------------------------------------------------
This message may contain information which is legally
privileged and/or confidential.  If you are not the
intended recipient, you are hereby notified that any
unauthorised disclosure, copying, distribution or use
of this information is strictly prohibited. Such
notification notwithstanding, any comments, opinions,
information or conclusions expressed in this message
are those of the originator, not of e-mango.com ltd,
unless otherwise explicitly and independently indicated
by an authorised representative of e-mango.com ltd.
-------------------------------------------------------
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to