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

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

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

转载于:https://www.cnblogs.com/yitian/archive/2008/09/16/1291407.html

猜你喜欢

转载自blog.csdn.net/weixin_33841722/article/details/93710332
今日推荐