Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Rude word filter

Posted on 2004-09-17
Medium Priority
Last Modified: 2012-03-15
Hi ppl!

I need to add a rude word filter to a webform to check if a user has entered an obscene word in a sentence stored in a string captured from a textbox. Can someone recommend a way of doing this in c#. Also does anyone know a source/library of common rude words to use?

Thanks for your help,
Question by:tnook
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

Expert Comment

ID: 12090328
This sounds like a classic parsing problem. Basically what you want to do is parse the text for your predefined rude words when the Textbox text is validating. I'll start you off by telling you to have a look at the Validating Events for the Textbox control and also the Regex class to help you with the parsing.

Do some reading on those and make an attempt at some code. If you have further problems then check back here and I'll try to help.
LVL 19

Expert Comment

by:Fahad Mukhtar
ID: 12090697
you can have an arraylist and then filll targat arraylist with all the common rude words...

if (RudeWords.Contains(InputWord)) //input word from user is being checked
//word is catch!!
LVL 18

Expert Comment

ID: 12091101
This link shows an example to do such things
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

LVL 10

Accepted Solution

ptmcomp earned 1600 total points
ID: 12091150
This could work similar to SPAM filters like K9. First parse the text and seperate words (e.g. using regex), then look them up in a hashtable/database.

Expert Comment

ID: 12091334
I agree with ptmcomp's suggestion:

                  string Commend= "I love this game game";

                  string []words= Commend.Split(new Char[] {' '});
                  Hashtable ht = new Hashtable();
                  for ( int i=0;i< words.Length;i++)
                        if ( !ht.ContainsKey(words[i].ToLower()) )
                  ArrayList badwords = new ArrayList();
                  bool bFind = false;
                  for ( int i=0;i<badwords.Count;i++)
                        if ( ht.ContainsKey(badwords[i]))

If the input is quite a long sentence, it will be more efficient than searching the whole string. But if the input is a different language which don't split words by space,  that's a different story.

Expert Comment

ID: 12093144
Don't forget that a poor implementation will earn you the scorn of all the inhabitants of Scunthorpe and Penistone.
LVL 10

Expert Comment

ID: 12102782
I know Scunthorpe is a place, and a football team, but is Penistone a place ?? never heard of that one.

Expert Comment

ID: 12105228
Indeed Penistone is a place. I imagine they suffer just as badly as Scunthorpe in the Internet filtering game. Still - Scunthorpe is more famous, if only because of the ill-fated proposal to change the name to Sconthorpe for Internet use. Talk about get a life!
LVL 10

Expert Comment

ID: 12105271
Then they'd have the trouble with whether to pronounce it Scone-Thorpe or Scon-Thorpe

Anyway... :-)

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

618 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