日期:2014-05-18  浏览次数:20478 次

正则过滤非中文问题
C# code
        string TempForm = Server.UrlDecode(Request.w.co

我这样写 无法正常过滤非中文字符 也就是说没有办法取出完全由中文组成的文字!

------解决方案--------------------
[\u4e00-\u9fa5]这个都过滤不了?
帮顶
------解决方案--------------------
string TempForm = Server.UrlDecode(Request.Form.ToString());
string tf="";

Regex regex = new Regex("([\u4e00-\u9fa5]+)");
for(Match match=regex.Match(TempForm ,0);match.Success;match=match.NexeMatch())
{
tf+=match.Groups[1].ToString();
}
------解决方案--------------------
探讨
string TempForm = Server.UrlDecode(Request.Form.ToString());
string tf="";

Regex regex = new Regex("([\u4e00-\u9fa5]+)");
for(Match match=regex.Match(TempForm ,0);match.Success;match=match.NexeMatch())
{
tf+=match.Groups[1].ToString();
}