Dirty word filter function has a problem

B

bay_dar

Hi my dirty word filter function has a problem, it is over restrictive.
For instance the word "analysis" is ok, but the word "anal" is not.

Any advice? code below:

Public Function IsHaveDirtyWord(ByVal a_str_Text As String) As String


Dim badWordFound As String
badWordFound = ""
Dim intCounter As Integer

Dim arraySize As Integer
arraySize = 30
Dim dirtyArray(arraySize) As String
dirtyArray(0) = "anal"
dirtyArray(1) = "butthead"
dirtyArray(2) = "clitoris"
dirtyArray(3) = "clitty"
dirtyArray(4) = "****"
dirtyArray(5) = "dildo"
dirtyArray(6) = "fart"
dirtyArray(7) = "****"
dirtyArray(8) = "gangbang"
dirtyArray(9) = "masturbat"
dirtyArray(10) = "meathope"
dirtyArray(11) = "nipple"
dirtyArray(12) = "pecker"
dirtyArray(13) = "penis"
dirtyArray(14) = "piss"
dirtyArray(15) = "pussy"
dirtyArray(16) = "rape"
dirtyArray(17) = "screw"
dirtyArray(18) = "shit"
dirtyArray(19) = "sperm"
dirtyArray(20) = "testicle"
dirtyArray(21) = "tittes"
dirtyArray(22) = "twat"
dirtyArray(23) = "vagina"
dirtyArray(24) = "whore"
dirtyArray(25) = "sodomy"
dirtyArray(26) = "slut"
dirtyArray(27) = "asswipe"
dirtyArray(28) = "asskisser"
dirtyArray(29) = "bastard"

For intCounter = 0 To arraySize - 1
If InStr(a_str_Text.ToLower, dirtyArray(intCounter)) <> 0
Then
badWordFound = dirtyArray(intCounter)
End If
Next
IsHaveDirtyWord = badWordFound
Return IsHaveDirtyWord

End Function
 
B

bay_dar

Really this is a serious question, can anybody help me?

The problem is the filter filters out good words like analysis because
of the 4 letters it starts with.

Thanks
 
B

Bruce Barker

normall you would add allowed roots along with unallowed.

say you disallowed disallowed

butt

which would also disallow the derivative

butthead

you would explicity allow

butte

which would allow the derivative

butter

-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,831
Latest member
HealthSmartketoReviews

Latest Threads

Top