Links to other sites
Officinado
Directory Search Site
1st Class Media
New media web development and hosting company
|
1st Class Home >> Developers - swear word filters.
As featured at ASPIN.com This VBScript function has a few simple rules,
- make sure your selected array of chosen words retains the spaces
- if you change the separator, refer to that within the "split" function
- make sure you choose an appropriate replacement string (we have found that being polite is best, you can't judge a posting by one expletive, so a simple *** normally suffices)
The Function:
<%
Function filterString(sString)
Dim filterArray
filterArray = split("http:// www. @ co.uk .com .net .org.uk .uk.com .co.ie .ie .org poo bum arse"," ")
'filterArray = Split(filterArray, vbNewline)
Dim i
For i = 0 To UBound(filterArray,1)
sString = Replace(sString,filterArray(i),String(Len(filterArray(i)),"**reference deleted**"),1,-1,1)
Next
filterString = sString
End Function
%>
The use of this filter would be <%=filterstring(rs("detail"))%> for displaying the processed description within a site.
Legend:
We normally refer to the function once it's been submitted to the database, if you strip the expletives from the submitted text prior to it being sent to the database, you've lost all reference to what was said originally (something which as administrator you may wish to use at a later stage when banning a user!)
Enjoy. |