Solved

rude word checker

Posted on 2006-10-27
8
505 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
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…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now