Censor Function:

The Censor function removes disallowed words from a string. Censored words are kept in a text file. The format of the text file is simple: one restricted word per line. The system will read the restricted words and replace all of those words with xxx's the same length as the removed word in the string. There is no limit to the amount of words that can be restricted.

Syntax:
string = Censor(uncensoredstring)
Example Usage:
<%
 ' ######
 ' contents of c:\dirtywords.txt:
 ' word1
 ' word2

dim a

 ' phrase to check
a = "Can you believe that word1 guy over there? What a word2 that guy is."

response.write Censor( a )

 ' returns:
 ' Can you believe that xxxxx guy over there? 
 ' What a xxxxx that guy is.
%>
ASP Source Code:
<%
Private Function Censor(byVal string)
	Const WordList = "C:\dirtywords.txt"
	Dim objFSO, objFile, tmp, item, word, a, b, x, y, i, c, j
	Set objFSO  = Server.CreateObject("Scripting.FileSystemObject")
	Set objFile = objFSO.OpenTextFile( WordList )
	tmp = split( objFile.ReadAll(), vbCrLf )
	objFile.Close
	Set objFile = Nothing
	Set objFSO  = Nothing
	x = split( string, " " )
	for i = 0 to ubound(x)
		a = x(i)
		For each item in tmp
			b = item
			if cstr(trim(lcase(a))) = _
			   cstr(Trim(lcase(b))) then
				c = Len(a)
				a = ""
				for j = 1 to c
					a = a & "x"
				next
				a = a & ""
				exit for
			end if
		next
		x(i) = a
	next
	Censor = Join( x, " " )
End Function
%>