PetShop 中的字符串过滤
Default 中的查詢...
1. WebUtility.SearchRedirect(txtSearch.Text);
namespace PetShop.Web {
???
??? public static class WebUtility {
??????? private const string REDIRECT_URL = "~/Search.aspx?keywords={0}";
??????
??????? public static string InputText(string text, int maxLength) {
??????????? text = text.Trim();
??????????? if (string.IsNullOrEmpty(text))
??????????????? return string.Empty;
??????????? if (text.Length > maxLength)
??????????????? text = text.Substring(0, maxLength);
??????????? text = Regex.Replace(text, "[\\s]{2,}", " "); //two or more spaces
??????????? text = Regex.Replace(text, "(<[b|B][r|R]/*>)+|(<[p|P](.|\\n)*?>)", "\n"); //<br>
??????????? text = Regex.Replace(text, "(\\s*&[n|N][b|B][s|S][p|P];\\s*)+", " "); //
??????????? text = Regex.Replace(text, "<(.|\\n)*?>", string.Empty); //any other tags
??????????? text = text.Replace("'", "''");
??????????? return text;
??????? }
public static void SearchRedirect(string key) {
??????????? HttpContext.Current.Response.Redirect(string.Format(REDIRECT_URL, InputText(key, 255)));
??????? }
??? }
}
轉載于:https://www.cnblogs.com/qinhaijun/archive/2011/08/26/2154399.html
總結
以上是生活随笔為你收集整理的PetShop 中的字符串过滤的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 大语言模型 + 磁共振技术,AI 已能解
- 下一篇: 网盘下载速度慢原因