C 特殊字元過濾函式

2022-02-26 16:16:17 字數 1151 閱讀 7451

using system;

using system.collections.generic;

using system.text;

using system.text.regularexpressions;

///

/// 對字串進行檢查和替換其中的特殊字元

///

///

///

public static string htmltotxt(string strhtml)

)|\s)*?(\/\s*)?>",

@"([\r\n])[\s]+",

@"&(quot|#34);",

@"&(amp|#38);",

@"&(lt|#60);",

@"&(gt|#62);",

@"&(nbsp|#160);",

@"&(iexcl|#161);",

@"&(cent|#162);",

@"&(pound|#163);",

@"&(copy|#169);",

@"&#(\d+);",

@"-->",

@"string newreg = aryreg[0];

string stroutput = strhtml;

for (int i = 0; i < aryreg.length; i++)

stroutput.replace("<", "");

stroutput.replace(">", "");

stroutput.replace("\r\n", "");

return stroutput;

}***************==另外兩個函式********************=

///

/// 替換html中的特殊字元

///

/// 需要進行替換的文字。

/// 替換完的文字。

public string htmlencode(string thestring)

///

/// 恢復html中的特殊字元

///

/// 需要恢復的文字。

/// 恢復好的文字。

public string htmldiscode(string thestring)

C 過濾特殊字元

1 過濾不安全的字串 public static string filtesqlstr string str 2.region 過濾 sql 語句字串中的注入指令碼 過濾 sql 語句字串中的注入指令碼 傳入的字串 過濾後的字串 public static string sqlfilter stri...

php 過濾特殊字元函式

1.過濾html str htmlspecialchars decode str str preg replace str 2.htmlspecialchars 函式把一些預定義的字元轉換為 html 實體。3.strip tags 函式剝去字串中的 html xml 以及 php 的標籤。4.ch...

過濾特殊字元

過濾特殊字元 public static string encoding string src 利用反射呼叫乙個繼承層次上的函式族,比如安裝程式,有安裝資料庫的,安裝檔案系統的等,命名均已 install 開始,你就可以將引數part設為 install src是其實類例項,root是終止父類 pu...