.net 去除特殊字符

str = Regex.Replace(str, @"<script[^>]*?>.*?</script>", "", RegexOptions.IgnoreCase);

//str为需要校验的字符

str = Regex.Replace(str, @"[~`@#$%^&*()_+{}|<>/\[]]", "", RegexOptions.IgnoreCase);

//删除与数据库相关的词
str= Regex.Replace(str, "select", "", RegexOptions.IgnoreCase);

原文地址:https://www.cnblogs.com/ljh19/p/10576613.html