Tag: character properties

正则表达式不匹配Unicode

我如何使用Regex匹配Unicode字符串? 我正在从文本文件中加载几个关键字,并在另一个文件中使用Regex。 关键字都包含unicode(例如á等)。 我不确定问题出在哪里。 我必须设置一些选项吗? 码: foreach (string currWord in _keywordList) { MatchCollection mCount = Regex.Matches( nSearch.InnerHtml, “\\b” + @currWord + “\\b”, RegexOptions.IgnoreCase); if (mCount.Count > 0) { wordFound.Add(currWord); MessageBox.Show(@currWord, mCount.ToString()); } } 并将关键字读入列表: var rdComp = new StreamReader(opnDiag.FileName); string compSplit = rdComp.ReadToEnd() .Replace(“\r\n”, “\n”) .Replace(“\n\r”, “\n”); rdComp.Dispose(); string[] compList = compSplit.Split(new[] {‘\n’}); 然后我将数组更改为列表。