Solved

rude word checker

Posted on 2006-10-27
8
519 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 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
Industry Leaders: 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 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

Industry Leaders: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.Net WebRequest Code from JSON curl 7 87
Expression Evaluater 3 45
vb.net class 3 28
VB.net Open video relating to control 2 29
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

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