public static void ParseData(string content, string fileName) { CSVParser parser = new CSVParser(); if (!parser.Parse(content)) { ClientLog.Instance.LogError("FilterwordData" + ConfigLoader.Instance.csvext + "解析错误"); return; } int recordCounter = parser.GetRecordCounter(); FilterwordData data = null; for (int i = 0; i < recordCounter; ++i) { data = new FilterwordData(); data._word = parser.GetString(i, "word"); if (!words.ContainsKey(data._word.Length)) { words.Add(data._word.Length, new List <string>()); } words[data._word.Length].Add(data._word); } parser.Dispose(); parser = null; }
void Filt(ref string matchStr, int start, int len) { if (len <= 0 || len > matchStr.Length) { return; } //????????? ??? string tStr = matchStr.Substring(start, len); if (tStr.Contains("*")) { if (start + len + 1 <= matchStr.Length) { Filt(ref matchStr, start + 1, len); } else { Filt(ref matchStr, 0, len + 1); } return; } //??????????? ??? List <string> fdata = FilterwordData.GetData(len); if (fdata == null) { if (start + len + 1 <= matchStr.Length) { Filt(ref matchStr, start + 1, len); } else { Filt(ref matchStr, 0, len + 1); } return; } //?? for (int i = 0; i < fdata.Count; ++i) { //???? if (tStr.Equals(fdata[i])) { // dsdfsdf Regex reg = new Regex(tStr); string partten = ""; for (int j = 0; j < len; ++j) { partten += "*"; } matchStr = reg.Replace(matchStr, partten, len, matchStr.IndexOf(tStr)); //????? if (start + len + 1 <= matchStr.Length) { Filt(ref matchStr, start + 1, len); } else { Filt(ref matchStr, 0, len + 1); } return; } } //???? ????? if (start + len + 1 <= matchStr.Length) { Filt(ref matchStr, start + 1, len); } else { Filt(ref matchStr, 0, len + 1); } }