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

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

 

相关文章: