QQ:6450046

正则表达式验证特殊字符串

 运行下面的函数需要using System.Text.RegularExpressions命名空间的支持。

 
  public bool checkString(string source)
  {
   Regex regExp=new Regex("[~!@#$%^&*()=+[\\]{}''\";:/?.,><`|!·¥…—()\\-、;:。,》《]");
   return !regExp.IsMatch(source);
  }
 

 

posted @ 2008-09-16 09:30  易 天  阅读(945)  评论(0编辑  收藏  举报