public void BadWordChecker_Test_False(string arg) { foreach (var val in arg) { Assert.False(BadWordChecker.CheckWord(arg)); } }
/// <summary> /// 字符串检测是否有敏感字并且替换为* /// </summary> /// <param name="strSoure">源字符串</param> /// <returns>新的字符串</returns> public static string replaceBadWordToStar(string strSoure) { if (badWords == null || badWords.Length == 0) { return(strSoure); } while (true) { string b = BadWordChecker.checkBadWord(strSoure); if (b == null) { break; } else { string star = "*"; for (int i = 1; i < b.Length; i++) { star += "*"; } strSoure = strSoure.Replace(b, star); } } return(strSoure); }
private static bool StringIsLegal(string _string) { bool legal = false; if (BadWordChecker.checkBadWord(_string) == null) { legal = true; } return(legal); }
/// <summary> /// 敏感字符检查 by 何明军 /// </summary> public bool CheckBadWord(string _text) { if (!isLoadFrom) { BadWordChecker.loadFromResources("Texture/Mingganzi"); isLoadFrom = true; } string str = BadWordChecker.checkBadWord(_text); if (str != null) { MessageST mst = new MessageST(); mst.messID = 299; mst.words = new string[1] { str }; GameCenter.messageMng.AddClientMsg(mst); return(false); } return(true); }