Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
JsonTerre1
Starting Member
9 Posts |
Posted - 2009-01-02 : 15:20:58
|
| I am developing a family friendly application for a client and they are allowing users to post info on it. I need to filter swear words. I have a table full of words although I would rather not do this on the server side. I would rather do the replace on the DB side. The data type could be a varchar(max) for the data searching and it may be nvarch(50). How can i search for words and replace them with the first letter and stars for the other letters using sql? I also have to account for where the word is. I don't want to replace a word that is in the middle of another word such as -ss when its in associates or something. You have words at the beginning or end of sentences so looking for a space before the word or/and after won't work either.Is it better to do it in code rather than in sql? I just wanted to keep it all in sql so it was compiled in case i needed to manage it.Any thoughts?j |
|
|
revdnrdy
Posting Yak Master
220 Posts |
Posted - 2009-01-02 : 15:54:25
|
| May I suggest you use the power of regular expressions to capture any undesirable words or phrases? This would be the easiest way in my view given all of the variations a swear word could have. It can also capture those inputs where the user tries to convey a swear using symbols in place of characters (like $h00t meaning shoot). You get the idea?Also I find this easier to do on the web side if it is web driven. You can filter the words and replace them with stars *** without the need to store and retrieve them. The words are captured and replaced dynamically.Otherwise you are confined to using a dictionary type approach where you reference words against a data table of naughty words. More maintenance in my view.My advice would be to go with regular expressions..r&r |
 |
|
|
darkdusky
Aged Yak Warrior
591 Posts |
Posted - 2009-01-09 : 11:38:24
|
| The book: MCTS Self-Paced Training Kit (Exam 70-431): Microsoft Sql Server 2005 Implementation and Maintenance has an interesting real world example of a similar scenario where the author compiled a dictionary of swear words etc.Some sites use a "report abuse or offensive language" link. |
 |
|
|
|
|
|