protected void Button1_Click(object sender, EventArgs e)
{
Response.Write(GetSearchText("请输入标题及时间,标题a,UUUU,QQQQ,RRRR,标题b,标题5,标题6,标题c,DDDD,EEEE,FFFF,GGGG,标题d,标题e,标题f,标题g,HHHH,标题h", "标题,a"));
}
public String GetSearchText(String content, String findTxt)
{
//return content.Replace(findTxt, "<b>" + findTxt + "</b>");
String[] arrTxt = content.Split(",".ToCharArray());
String[] arrfindTxt = findTxt.Split(",".ToCharArray());
String result = "";
for (int i = 0; i < arrTxt.Length; i++)
{
for (int j = 0; j < arrfindTxt.Length; j++)
{
if (arrTxt[i].IndexOf(arrfindTxt[j]) > -1)
{
arrTxt[i] = arrTxt[i].Replace(arrfindTxt[j], "<b>" + arrfindTxt[j] + "</b>");
}
}
result = result + arrTxt[i]+",";
}
return result;
}
这样是你想要的结果么?
[bc09] 犯强汉者,虽远比诛!