using System.Text.RegularExpressions;
using System.Collections.Generic;
public static string StripDomains(string text, string replacement = "")
Regex reFull = new Regex(@"http\w*://([-A-Z0-9+&@#/%=~_|$?!:,.]+\.)+[a-z]{2,}[^\s,]*",
RegexOptions.IgnoreCase | RegexOptions.Multiline);
text = reFull.Replace(text, replacement);
string domains = "(com|net|org|info|co.uk|fr|biz|io|edu|gov|mil|aero|mobi|name)";
Regex rePart = new Regex(@"([-A-Z0-9+&@#/%=~_|$?!:,.]+\.)+" + domains + "[^\\s,]*",
RegexOptions.IgnoreCase | RegexOptions.Multiline);
text = rePart.Replace(text, replacement);
public static string StripBlacklisted(string text, string[] blacklist, string repl = "")
foreach (string str in blacklist) {
text = ReplaceText(text, str, repl);
public static string ReplaceText(string text, string find, string repl = "")
Regex re = new Regex(@find, RegexOptions.IgnoreCase | RegexOptions.Multiline);
text = re.Replace(text, repl);
public static string FormatText(Dictionary<string, string> keywords, string text)
foreach (KeyValuePair<string, string> keyword in keywords) {
text = ReplaceText(text, keyword.Key, keyword.Value);
public static void Main()
string text = "Hello säläm this Բարեւ is an Héébee Salü Emoji ☺ ✌ \ud83d\udc59 ✈ Бзиа збаша\ud83d\ude18 \ud83d\ude0d Ç'kemi\ud83d\udcaa Ç'kemi 你好 \ud83d\udc9b \ud83d\udc38 \ud83d\ude02 ☁ ⚡ ⛄";
Console.WriteLine("Original:\n" + text);
String[] blacklist = new string[] {
@"(?<=\s|^)([\u1F60-\uFFFF]+|([O3>]|)[:;8](?:[\-'|]|)[)(\]\[DPO*v3|/]|[oO\-^][._][oO\-^]|<3|\((?:y|[\^]{3})\)|:[a-z]{2,8}:|<\(\""\))(?=\s|$)",
text = StripBlacklisted(text, blacklist);
Console.WriteLine("-----");
Console.WriteLine("Stripped Blacklisted:\n" + text);