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'在第一次迭代中終止其執行。 –