0
Iam尝试突出显示gridview中的多个关键字。我尝试使用forloop,但仅突出显示数组中的第一项。突出显示多个关键字
protected string HighlightText(string searchWord, string inputText)
{
// string[] strArray = new string[] { "Hello", "Welcome" };
string s = "d,s";
// Split string on spaces.
// ... This will separate all the words.
string[] words = s.Split(',');
for (int i = 0; i < words.Length; i++)
{
//Console.WriteLine(word);
searchWord = words[i];
Regex expression = new Regex(searchWord.Replace(" ", "|"), RegexOptions.IgnoreCase);
return expression.Replace(inputText, new MatchEvaluator(ReplaceKeywords));
}
return string.Empty;
}
高级谢谢。
这是出把荫只获得关键字“d”得到强调需要特别提出的关键字“S”也...
循环内部的'return'在第一次迭代中终止其执行。 –