using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
namespace Web.Tool
{
public class HandleString
{
///
/// 在页面上调试直接输出
///
/// 要输出的内容
public static void Debug(string str)
{
HttpContext.Current.Response.Write(str);
HttpContext.Current.Response.End();
}
///
/// 倒序输出
///
/// 要转换的字符串
/// 输出的结果
public static string DotReverse(string str)
{
string str2 = "";
for (int i = str.Length - 1; i > -1; i--)
{
str2 = str2 + str.Substring(i, 1);
}
return str2;
}
///
/// 获取随机字母字符串
///
/// 长度
/// 生成好的字符串
public static string GenRndString(int len)
{
char[] chArray = ("ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToLower()).ToCharArray();
string str2 = string.Empty;
Random random = new Random();
for (int i = 0; i < len; i++)
{
int num = random.Next();
str2 = str2 + chArray[num % 50].ToString();
}
return str2;
}
///
/// JS过滤
///
/// 要过滤的字符串
/// 过滤字符
/// 返回过滤后的字符串
public static string JsFilter(string str, string exclueStr)
{
if (exclueStr.IndexOf(",") < 0)
{
str = str.Replace("", "");
}
if (exclueStr.IndexOf("javascript,") < 0)
{
str = str.Replace("javascript", "");
}
if (exclueStr.IndexOf("/,") < 0)
{
str = str.Replace("/", "");
}
if (exclueStr.IndexOf("',") < 0)
{
str = str.Replace("'", "");
}
if (exclueStr.IndexOf(";,") < 0)
{
str = str.Replace(";", "");
}
if (exclueStr.IndexOf("&,") < 0)
{
str = str.Replace("&", "");
}
if (exclueStr.IndexOf("#,") < 0)
{
str = str.Replace("#", "");
}
return str;
}
///
/// html标签过滤
///
/// html代码
/// 返回处理过的代码
public static string NoHTML(string Htmlstring)
{
Htmlstring = Regex.Replace(Htmlstring, "", "", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, "<(.[^>]*)>", "", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, @"([\r\n])[\s]+", "", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, "-->", "", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, "