All Projects → jamesmontemagno → Censored

jamesmontemagno / Censored

Licence: mit
A .NET Profanity Censoring Library

Censored - A .NET Profanity Censoring Library

A .NET library to easily detect and censor words. Specify the list of words you wish to censor and Censored will automatically replace them with *****. If you want to just check if a censored word exists in a sentence you can do that too.

Inspired by a blog from James Newton-King and code used with permission.

Grab the NuGet: https://www.nuget.org/packages/Censored/ NuGet

Build Status: Build status

Built with C# 6 features, you must be running VS 2015 or Xamarin Studio to compile. NuGets of course work everywhere!

Usage

var censoredWords = new List<string>
{
  "gosh",
  "drat",
  "darn*",
};
 
var censor = new Censor(censoredWords);
string result;

 
result = censor.CensorText("I stubbed my toe. Gosh it hurts!");
// I stubbed my toe. **** it hurts!
 
result = censor.CensorText("The midrate on the USD -> EUR forex trade has soured my day. Drat!");
// The midrate on the USD -> EUR forex trade has soured my day. ****!
 
result = censor.CensorText("Gosh darnit, my shoe laces are undone.");
// **** ******, my shoe laces are undone.


bool hasCensoredWord;

hasCensoredWord = censor.HasCensoredWord("I stubbed my toe. Gosh it hurts!");
// true

hasCensoredWord = censor.HasCensoredWord("I stubbed my toe. It hurts!");
// false

You can find a nice list of words to censor at: http://www.bannedwordlist.com

License

Under MIT (please see LICENSE file)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].