文章里动态关键字的做法
我想问下那些大型门户网站里新闻的特定关键字是怎么做的
就是像网易那里的一些特定的关键字,会自动生成一个链接
------解决方案--------------------up
------解决方案--------------------C#原代源,如哪位高手有更好的做法请发到我邮箱,我的邮箱SAM_1031@163.COM
private string AddKeyWord(string strInfo,string strKeyWord,string strKeyWordUrl)
{
string strInfos = "";
int count;
string strUrl = "<a href=\"" + strKeyWordUrl + "\">" + strKeyWord + "</a>";
while (true)
{
count = strInfo.IndexOf("<");
if (count != -1)
{
strInfos += strInfo.Substring(0, count).Replace(strKeyWord, strUrl);
strInfo = strInfo.Substring(count);
count = strInfo.IndexOf(">");
if (count != -1)
{
if (strInfo.Substring(0, 2).ToLower() == "<a")
{
count = strInfo.ToLower().IndexOf("</a>") + 4;
strInfos += strInfo.Substring(0, count);
strInfo = strInfo.Substring(count);
}
else
{
count++;
strInfos += strInfo.Substring(0, count);
strInfo = strInfo.Substring(count);
}
}
else
{
strInfos += strInfo;
return strInfos;
}
}
else
{
strInfos += strInfo.Replace(strKeyWord, strUrl);
return strInfos;
}
}
}