1添加命名空间:using System.Text.RegularExpressions;
2在需要的地方添加如下代码:
string str = "sR seeD ";
MatchCollection mc = Regex.Matches(str.Trim(),"srseed",RegexOptions.IgnoreCase);
if (mc == null)
Response.Write("<script>alert('匹配失败!')</script>");
else
Response.Write("<script>alert('匹配成功!')</script>");
MatchCollection mc = Regex.Matches(str.Trim(),"srseed",RegexOptions.IgnoreCase);
if (mc == null)
Response.Write("<script>alert('匹配失败!')</script>");
else
Response.Write("<script>alert('匹配成功!')</script>");
3这样更可以在cs页面验证aspx的控件,正则表达式!
本文转自 韬光星夜 51CTO博客,原文链接:http://blog.51cto.com/xfqxj/477073,如需转载请自行联系原作者