代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
CSharp
】
字符串格式化通用类
作者:
CSDN
/ 发布于
2012/1/11
/
972
<div><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">class</span><span style="color: rgb(0,0,0)"> FormatStr { </span><span style="color: rgb(0,0,255)">#region</span><span style="color: rgb(0,0,0)"> MD5加密</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> MD5加密操作 </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="str"></span><span style="color: rgb(0,128,0)">加密的字符串</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><returns></returns></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">static</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> MD5(</span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> str) { </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">MD5</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">); } </span><span style="color: rgb(0,0,255)">#endregion</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">#region</span><span style="color: rgb(0,0,0)"> 去除HTML标记</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 去除HTML标记 </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="NoHTML"></span><span style="color: rgb(0,128,0)">包括HTML的源码 </span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><returns></span><span style="color: rgb(0,128,0)">已经去除后的文字</span><span style="color: rgb(128,128,128)"></returns></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">static</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> NoHTML(</span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> Htmlstring) { </span><span style="color: rgb(0,128,0)">//</span><span style="color: rgb(0,128,0)">删除脚本</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(0,0,0)"> Htmlstring </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> Regex.Replace(Htmlstring, </span><span style="color: rgb(128,0,0)">@"</span><span style="color: rgb(128,0,0)"><script[^>]*?>.*?</script></span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">""</span><span style="color: rgb(0,0,0)">, RegexOptions.IgnoreCase); </span><span style="color: rgb(0,128,0)">//</span><span style="color: rgb(0,128,0)">删除HTML</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(0,0,0)"> Htmlstring </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> Regex.Replace(Htmlstring, </span><span style="color: rgb(128,0,0)">@"</span><span style="color: rgb(128,0,0)"><(.[^>]*)></span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">""</span><span style="color: rgb(0,0,0)">, RegexOptions.IgnoreCase); Htmlstring </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> Regex.Replace(Htmlstring, </span><span style="color: rgb(128,0,0)">@"</span><span style="color: rgb(128,0,0)">([\r\n])[\s]+</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">""</span><span style="color: rgb(0,0,0)">, RegexOptions.IgnoreCase); Htmlstring </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> Regex.Replace(Htmlstring, </span><span style="color: rgb(128,0,0)">@"</span><span style="color: rgb(128,0,0)">--></span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">""</span><span style="color: rgb(0,0,0)">, RegexOptions.IgnoreCase); Htmlstring </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> Regex.Replace(Htmlstring, </span><span style="color: rgb(128,0,0)">@"</span><span style="color: rgb(128,0,0)"><!--.*</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">""</span><span style="color: rgb(0,0,0)">, RegexOptions.IgnoreCase); Htmlstring </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> Regex.Replace(Htmlstring, </span><span style="color: rgb(128,0,0)">@"</span><span style="color: rgb(128,0,0)">&(quot|#34);</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">\"</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, RegexOptions.IgnoreCase); Htmlstring </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> Regex.Replace(Htmlstring, </span><span style="color: rgb(128,0,0)">@"</span><span style="color: rgb(128,0,0)">&(amp|#38);</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">&</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, RegexOptions.IgnoreCase); Htmlstring </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> Regex.Replace(Htmlstring, </span><span style="color: rgb(128,0,0)">@"</span><span style="color: rgb(128,0,0)">&(lt|#60);</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)"><</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, RegexOptions.IgnoreCase); Htmlstring </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> Regex.Replace(Htmlstring, </span><span style="color: rgb(128,0,0)">@"</span><span style="color: rgb(128,0,0)">&(gt|#62);</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">></span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, RegexOptions.IgnoreCase); Htmlstring </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> Regex.Replace(Htmlstring, </span><span style="color: rgb(128,0,0)">@"</span><span style="color: rgb(128,0,0)">&(nbsp|#160);</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)"> </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, RegexOptions.IgnoreCase); Htmlstring </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> Regex.Replace(Htmlstring, </span><span style="color: rgb(128,0,0)">@"</span><span style="color: rgb(128,0,0)">&(iexcl|#161);</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">\xa1</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, RegexOptions.IgnoreCase); Htmlstring </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> Regex.Replace(Htmlstring, </span><span style="color: rgb(128,0,0)">@"</span><span style="color: rgb(128,0,0)">&(cent|#162);</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">\xa2</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, RegexOptions.IgnoreCase); Htmlstring </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> Regex.Replace(Htmlstring, </span><span style="color: rgb(128,0,0)">@"</span><span style="color: rgb(128,0,0)">&(pound|#163);</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">\xa3</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, RegexOptions.IgnoreCase); Htmlstring </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> Regex.Replace(Htmlstring, </span><span style="color: rgb(128,0,0)">@"</span><span style="color: rgb(128,0,0)">&(copy|#169);</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">\xa9</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, RegexOptions.IgnoreCase); Htmlstring </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> Regex.Replace(Htmlstring, </span><span style="color: rgb(128,0,0)">@"</span><span style="color: rgb(128,0,0)">&#(\d+);</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">""</span><span style="color: rgb(0,0,0)">, RegexOptions.IgnoreCase); Htmlstring.Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)"><</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">""</span><span style="color: rgb(0,0,0)">); Htmlstring.Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">></span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">""</span><span style="color: rgb(0,0,0)">); Htmlstring.Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">\r\n</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">""</span><span style="color: rgb(0,0,0)">); Htmlstring </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> HttpContext.Current.Server.HtmlEncode(Htmlstring).Trim(); </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> Htmlstring; } </span><span style="color: rgb(0,0,255)">#endregion</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">#region</span><span style="color: rgb(0,0,0)"> 去除非法字串</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 去除非法字串 </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="strChar"></span><span style="color: rgb(0,128,0)">原字串</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><returns></span><span style="color: rgb(0,128,0)">过滤过的字串</span><span style="color: rgb(128,128,128)"></returns></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">static</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> ReplaceBadChar(</span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> strChar) { </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> (strChar.Trim() </span><span style="color: rgb(0,0,0)">==</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,0,0)">""</span><span style="color: rgb(0,0,0)">) { </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,0,0)">""</span><span style="color: rgb(0,0,0)">; } </span><span style="color: rgb(0,0,255)">else</span><span style="color: rgb(0,0,0)"> { strChar </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> strChar.Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">'</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">""</span><span style="color: rgb(0,0,0)">); strChar </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> strChar.Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">*</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">""</span><span style="color: rgb(0,0,0)">); strChar </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> strChar.Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">?</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">""</span><span style="color: rgb(0,0,0)">); strChar </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> strChar.Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">""</span><span style="color: rgb(0,0,0)">); strChar </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> strChar.Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">)</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">""</span><span style="color: rgb(0,0,0)">); strChar </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> strChar.Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)"><</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">""</span><span style="color: rgb(0,0,0)">); strChar </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> strChar.Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">=</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">""</span><span style="color: rgb(0,0,0)">); </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> strChar.Trim(); } } </span><span style="color: rgb(0,0,255)">#endregion</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">#region</span><span style="color: rgb(0,0,0)"> 检察是否都是数字</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 检察是否都是数字 </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="str"></span><span style="color: rgb(0,128,0)">要检查的字串</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><returns></span><span style="color: rgb(0,128,0)">bool</span><span style="color: rgb(128,128,128)"></returns></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">static</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">bool</span><span style="color: rgb(0,0,0)"> IsNumeric(</span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> str) { Regex reg </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> Regex(</span><span style="color: rgb(128,0,0)">@"</span><span style="color: rgb(128,0,0)">^[+]?\d*$</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">); </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> reg.IsMatch(str); } </span><span style="color: rgb(0,0,255)">#endregion</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">#region</span><span style="color: rgb(0,0,0)"> 检察是否正确的Email格式</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 检察是否正确的Email格式 </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="str"></span><span style="color: rgb(0,128,0)">要检查的字串</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><returns></span><span style="color: rgb(0,128,0)">bool</span><span style="color: rgb(128,128,128)"></returns></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">static</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">bool</span><span style="color: rgb(0,0,0)"> IsEmail(</span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> str) { Regex reg </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> Regex(</span><span style="color: rgb(128,0,0)">@"</span><span style="color: rgb(128,0,0)">^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">); </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> reg.IsMatch(str); } </span><span style="color: rgb(0,0,255)">#endregion</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">#region</span><span style="color: rgb(0,0,0)"> 检察是否正确的日期格式</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 检察是否正确的日期格式 </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="str"></span><span style="color: rgb(0,128,0)">要检查的字串</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><returns></span><span style="color: rgb(0,128,0)">bool</span><span style="color: rgb(128,128,128)"></returns></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">static</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">bool</span><span style="color: rgb(0,0,0)"> IsDate(</span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> str) { </span><span style="color: rgb(0,128,0)">//</span><span style="color: rgb(0,128,0)">考虑到了4年一度的366天,还有特殊的2月的日期</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(0,0,0)"> Regex reg </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> Regex(</span><span style="color: rgb(128,0,0)">@"</span><span style="color: rgb(128,0,0)">^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-)) (20|21|22|23|[0-1]?\d):[0-5]?\d:[0-5]?\d$</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">); </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> reg.IsMatch(str); } </span><span style="color: rgb(0,0,255)">#endregion</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">#region</span><span style="color: rgb(0,0,0)"> HTML转换为字符串</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> HTML转换为字符串,转换标识 </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="str"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><returns></returns></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">static</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> htmToStr(</span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> str) { </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> str.Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">\'</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">mySQ;</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">\"</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">myDQ;</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)"><</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">myLt;</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">></span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">myGt;</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">-</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">myMl;</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">_</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">myBl;</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">%</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">myBs;</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">?</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">myQe;</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">*</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">myAl;</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">); } </span><span style="color: rgb(0,0,255)">#endregion</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">#region</span><span style="color: rgb(0,0,0)"> 字符串转换为HTML</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 字符串转换为HTML,将还原标识 </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="str"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><returns></returns></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">static</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> strToHtm(</span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> str) { </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> (str </span><span style="color: rgb(0,0,0)">==</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">null</span><span style="color: rgb(0,0,0)">) </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,0,0)">""</span><span style="color: rgb(0,0,0)">; </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> str.Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">mySQ;</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">\'</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">myDQ;</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">\"</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">myLt;</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)"><</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">myGt;</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">></span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">myMl;</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">-</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">myBl;</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">_</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">myBs;</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">%</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">myQe;</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">?</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">myAl;</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">*</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">); } </span><span style="color: rgb(0,0,255)">#endregion</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">#region</span><span style="color: rgb(0,0,0)"> 文本转换为HTML</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 文本转换为HTML,更换(\n) </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="str"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><returns></returns></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">static</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> textToHtm(</span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> str) { </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> str.Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">\t</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)"> </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)"><</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)"><</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">></span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">></span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)"> </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)"> </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">\r\n</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)"></span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">\n</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)"></span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">); } </span><span style="color: rgb(0,0,255)">#endregion</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">#region</span><span style="color: rgb(0,0,0)"> 文本转换为输入框内容</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 文本转换为输入框内容, </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="str"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><returns></returns></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">static</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> HtmToInputValue(</span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> str) { </span><span style="color: rgb(0,128,0)">//</span><span style="color: rgb(0,128,0)">return str.Replace("<","<").Replace(">",">").Replace("\"",""").Replace("&","&");</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> str.Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">\"</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">); } </span><span style="color: rgb(0,0,255)">#endregion</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">#region</span><span style="color: rgb(0,0,0)"> 防Sql注入攻击</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 防Sql注入攻击 </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="strQueryName"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><returns></returns></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">static</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> getQueryString(</span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> strQueryName) { </span><span style="color: rgb(0,128,0)">//</span><span style="color: rgb(0,128,0)">(')(--)(or )(=)</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(0,0,0)"> System.Web.HttpRequest myRequest </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> System.Web.HttpContext.Current.Request; </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> str1 </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> myRequest.QueryString[strQueryName]; </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> (str1 </span><span style="color: rgb(0,0,0)">==</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">null</span><span style="color: rgb(0,0,0)">) </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,0,0)">""</span><span style="color: rgb(0,0,0)">; str1 </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> str1.Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">'</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">’</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">--</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">—</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">=</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">=</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">or</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">o r</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">Or</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">O r</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">OR</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">O R</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">oR</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">o R</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">></span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">〉</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)"><</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">〈</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">); </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> str1; } </span><span style="color: rgb(0,0,255)">#endregion</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">#region</span><span style="color: rgb(0,0,0)"> 防Sql注入攻击</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 防Sql注入攻击 </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="strQueryName"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><returns></returns></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">static</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> getSQLString(</span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> strQueryName) { </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> (strQueryName </span><span style="color: rgb(0,0,0)">==</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">null</span><span style="color: rgb(0,0,0)">) </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,0,0)">""</span><span style="color: rgb(0,0,0)">; strQueryName </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> strQueryName.Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">'</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">’</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">--</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">—</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">=</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">=</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">or</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">o r</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">Or</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">O r</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">OR</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">O R</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">oR</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">o R</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">></span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">〉</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Replace(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)"><</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">〈</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">); </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> strQueryName; } </span><span style="color: rgb(0,0,255)">#endregion</span><span style="color: rgb(0,0,0)"> } </span> </div>
试试其它关键字
字符串格式化
同语言下
.
文件IO 操作类库
.
Check图片类型[JPEG(.jpg 、.jpeg),TIF,GIF,BMP,PNG,P
.
机器名和IP取得(IPV4 IPV6)
.
Tiff转换Bitmap
.
linqHelper
.
MadieHelper.cs
.
RegHelper.cs
.
如果关闭一个窗体后激活另一个窗体的事件或方法
.
创建日志通用类
.
串口辅助开发类
可能有用的
.
C#实现的html内容截取
.
List 切割成几份 工具类
.
SQL查询 多列合并成一行用逗号隔开
.
一行一行读取txt的内容
.
C#动态修改文件夹名称(FSO实现,不移动文件)
.
c# 移动文件或文件夹
.
c#图片添加水印
.
Java PDF转换成图片并输出给前台展示
.
网站后台修改图片尺寸代码
.
处理大图片在缩略图时的展示
CSDN
贡献的其它代码
(
27
)
.
xml操作类
.
完全无组件,不用调用Excel.exe 导出数据到Excel
.
DropDownList手动构造一个下拉树形
.
判断是否低于IE6的版本
.
javascript 鼠标拖拉画图
.
取汉字首字母
.
字符串格式化通用类
.
mssql海量高效分页存储过程
.
.net 获取远程IP 得到省市
.
javascript 模仿windows拖动 封装类
Copyright © 2004 - 2024 dezai.cn. All Rights Reserved
站长博客
粤ICP备13059550号-3