You might try adding a "regular expression" in the ReplaceNoCase function,
both before and after the badword string, so that punctuation and spaces on
either side of badword would match, but alphabet characters would not match.
This should adress the "embedded bad word" problem.
For more info, see the chapter on regular expressions in "Developing web
applications with Cold Fusion". It's chapter 8 in the CF 4.0 manual, but
for some reason seems to be missing from the 4.5 manual. In any case, a
good UNIX book will have the information you need (regular expressions
originated in the UNIX world).
Good luck,
Kevin
-----Original Message-----
From: Will Swain [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 06, 2001 10:56 PM
To: CF-Talk
Subject: profanity checker(again)
Hi all,
I emailed the list regarding this a few weeks ago, but an interesting
problem has now come up.
I have some code that pulls a list of profanities from a db table, then
checks them against a form feild submitted by a user. Any words that
match
are asterisked out. All well and good. But, when someone entered
Saturday,
the code returned Sa****ay!! Yers, turd is in the database! What I want
to
know is this. How would I look at changing this so that whilst turd
would be
picked up and returned as ****, saturday is not??
Any ideas? Code is below.
TIA
Will
<cfset bodytext = Form.thread_body>
<cfset titletext = Form.thread_title>
<!--- 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#",
"#getprofanities.rate1#", "ALL")>
<cfset titletext = ReplaceNoCase(titletext,
"#getprofanities.badword#",
"#getprofanities.rate1#", "ALL")>
</cfloop>
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists