Posted by:
Carlos on
16/06/2008 21:40:38
You must be logged in to vote on thread ratings
In the past couple of years I, and my colleague, have created several online communities (quite successful ones i might add) and two fairly important parts of these communities are the forums and chatrooms. If you've used online forums/message boards before then you've probably noticed that the majority of them use a swear filter / language filter.
In the past couple of years I, and my colleague, have created several
online communities (quite successful ones i might add) and two fairly
important parts of these communities are the
forums and chatrooms. If
you've used online forums/message boards before then you've probably
noticed that the majority of them use a swear filter / language filter.
Because we didn't use an "Out of the box" forum package for our
communities we had to create our own filters using
ASP / VBScript.
Here is an example of a fairly simple
ASP based language filter
function:
Function Language_Filter(s)
dim badwordsfilter,badWords,regEx,badword
badwordsfilter="word1,word2,word3,"
badWords = Split(badWordsFilter, ",")
Set regEx = New RegExp
regEx.IgnoreCase = True
regEx.Global = True
For Each badWord In badWords
badWord = Trim(badWord)
regEx.Pattern = "(\s"&badWord&"\s)|(^"&badword&")|(^"&badword&"$)|("&badword&"$)"
regEx.Pattern = "\b"&badWord&"\b"
s = regEx.Replace(s, padBadWordWithAsterisks(badWord))
Next
Language_Filter = s
Set RegEx=Nothing
end function
Bear
in mind that this would probably be used after any other "cleaning" of
the input text for invalid / dangerous characters. (We will look at
that in another post)
There are no comments yet. Be the first to post!