正则表达式简单使用_找到a标签将连接地址转码
Regexreg=newRegex("){1}");//匹配
RegexregHref=newRegex("path=(.*)[\"|']");//匹配path="*"
stringstrNewsContentTemp=FCKeditor_NewsEditor.Value;//abcabcbc
stringyuan="";
stringmu="";
MatchCollectionmatches=reg.Matches(strNewsContentTemp);//匹配结果的集合
for(inti=0;i
if(regHref.IsMatch(yuan))//如果含有path="*"
{
stringhrefYuan=regHref.Matches(yuan)[0].Value;//path=/中文.aspx"
hrefYuan=hrefYuan.Substring(0,hrefYuan.Length-1);//path=/中文.aspx
hrefYuan=hrefYuan.Substring(6);//中文.aspx
stringhrefMu=Server.UrlEncode(hrefYuan);//转码
mu=yuan.Replace(hrefYuan,hrefMu);//替换字符串不认识的.aspx
strNewsContentTemp=strNewsContentTemp.Replace(yuan,mu);//将中的中文.aspx换成不认识的.aspx
}
}
News.NewsContent=strNewsContentTemp;