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
Solved

rude word checker

Posted on 2006-10-27
8
518 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
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 17

Assisted Solution

by:ZeonFlash
ZeonFlash earned 100 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 100 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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 300 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

856 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