/// <summary>
/// 过滤特殊字符
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public static string FilterSpecial(this string str)
{
if (str == string.Empty) //如果字符串为空,直接返回。
{
return str;
}
else
{
str = str.Replace("'", string.Empty);
str = str.Replace("<", string.Empty);
str = str.Replace(">", string.Empty);
//str = str.Replace("%", string.Empty);
str = str.Replace("'delete", string.Empty);
str = str.Replace("''", string.Empty);
str = str.Replace(",", string.Empty);
str = str.Replace(".", string.Empty);
str = str.Replace(">=", string.Empty);
str = str.Replace("=<", string.Empty);
str = str.Replace("-", string.Empty);
str = str.Replace("_", string.Empty);
str = str.Replace(";", string.Empty);
str = str.Replace("||", string.Empty);
str = str.Replace("[", string.Empty);
str = str.Replace("]", string.Empty);
str = str.Replace("&", string.Empty);
str = str.Replace("/", string.Empty);
str = str.Replace("-", string.Empty);
str = str.Replace("|", string.Empty);
str = str.Replace("?", string.Empty);
str = str.Replace(">?", string.Empty);
str = str.Replace("?<", string.Empty);
str = str.Replace(" ", string.Empty);
return str;
}
}