使用正则表达式查找替换所有的HTML代码为空就可以了。
/<(.*)>.*<\/\1>/这个就是匹配的所有html代码的正则。
补充:
using System.Text.RegularExpressions;//需要引用
// 利用正则表达式去掉"<"和">"之间的内容
private string StripHT(string strHtml)
{
Regex regex=new Regex("<.+?>",RegexOptions.IgnoreCase);
string strOutput=regex.Replace(strHtml,"");
return strOutput;
}
using System.Text.RegularExpressions;
string str="fdsa汉jklfda字ljklfdsa提jkflds取ljfjkds";
Regex rg = new Regex(@"[\u4e00-\u9fa5]");
str = rg.Match(str).ToString(); Response.Write(str);
---------------------
你自己加个循环嘛...
string str="fdsa汉jklfda字ljklfdsa提jkflds取ljfjkds";
string newstr="";
Regex rg = new Regex(@"[\u4e00-\u9fa5]");
for(int ii=0;ii
if(rg.IsMatch(val)){
newstr+=val;
}
}
Response.Write(newstr);
简单你看看 汉字在UNICODE编码里面的范围 就知道了