?
Solved

rude word checker

Posted on 2006-10-27
8
Medium Priority
?
526 Views
Last Modified: 2012-08-14
Hi

I'm creating a website where the user can invent their own screen name. I want to make sure they don't come up with one containing swear words. can you advise how i would create a dictionary (or something) of rude words and name sure the screen name does not contain them.

In a screen name, what characters should i allow and disallow. I know underscores are useful but what about other characters, should i disallow them for simplicity?

thanks
andrea
0
Comment
Question by:andieje
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 17

Assisted Solution

by:ZeonFlash
ZeonFlash earned 400 total points
ID: 17821233
To address the second part of your question, you should avoid allowing users to use characters that SQL uses as keywords.  This includes single quotes ('), remarks (-- or /* or */), and the wildcard operator (%).  In fact, it's generally easiest to run the user's suggested name through a regex that only allows for A-Z and 0-9 (and, as you mentioned, underscores).
0
 
LVL 10

Assisted Solution

by:gangwisch
gangwisch earned 400 total points
ID: 17821252
the best way to do this is to put your swear words into an arraylist
dim swearwords as new arraylist
swearwords.add("cussword1")
swearwords.add("cussword2")

function checkIfHasSwearWords(byval username as string,byval a as arraylist) as boolean
for each item as string in a
if instr(username,item)>0 then return true
next
return false 'false if it doesnt have swear words in it
end function

good luck
0
 
LVL 10

Expert Comment

by:gangwisch
ID: 17821272
oh yeah another comment:
change
if instr(username,item)>0 then return true
to
if instr(username.tolower,item)>0 then return true

and change all your curse words in the arraylist to lowercase

sorry about that
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:JeffvClayton
ID: 17822127
You could just type all your swear words in to a text file and use instr() function to check if any word in the file matches the login
0
 

Author Comment

by:andieje
ID: 17822192
Thanks for your replies

Jeff, how would i do that option. Would i have one swear word per line? Could you give me some example code? I hanvet done much file manipulation.

thanks
andrea
0
 
LVL 3

Accepted Solution

by:
JeffvClayton earned 1200 total points
ID: 17822311
just type each word as you would in a word document leaviing a space between each word. save as MySwearwords.txt. You could do this in notepad.

Read the entire file in using a textstream object and use the instr funtion to check for the password/swearword in the textstream objecte e.g

dim pos as long

    pos =  InStr(strContents, MySwearWord, CompareMethod.Text)                ....see function below for strContents

     pos will be 0 if no match found, otherwise pos will equal the start position of MySwearWord (password)

   Ypu may also want to loop through all your words in the text file to check in reverse against the password in case they have used a combination of other characters ans a swear word.

it may be better tp put each swearword on a new line in consideration of the loop for checking back to see if any part of the password is a swear word.

Heres some quick code to get your text file in to a variable: nothing checked as its late where i am (UK) but i will tomorrow. Full path = say C:\MyTextFile.txt

Public Function GetFileContents(ByVal FullPath As String, _
       Optional ByRef ErrInfo As String = "") As String

        Dim strContents As String
        Dim objReader As StreamReader
        Try

            objReader = New StreamReader(FullPath)
            strContents = objReader.ReadToEnd()
            objReader.Close()
            Return strContents
        Catch Ex As Exception
            ErrInfo = Ex.Message
        End Try
    End Function
0
 
LVL 3

Expert Comment

by:JeffvClayton
ID: 17822316
Hope this enough to get you going before tomorrow

Jeff
0
 

Author Comment

by:andieje
ID: 17822448
THANKS a lot
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question