過濾HTML標籤的幾個函式

2021-08-20 15:15:14 字數 1319 閱讀 8478

/**/ ///  

///   去除html標記

///  

///   包括html的原始碼  

///   已經去除後的文字

public static string nohtml(string htmlstring)

public static string striphtml(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+);", @"-->", @"

"", "", "", "\"", "&", "<", ">", "   ", "\xa1",  //chr(161),

"\xa2",  //chr(162),

"\xa3",  //chr(163),

"\xa9",  //chr(169),

"", "\r\n", ""

};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標籤

#region

///移除html標籤

/**/ ///  

///   移除html標籤

///  

///   htmlstr

public static string parsetags(string htmlstr)

#endregion

///   取出文字中的位址

#region

///   取出文字中的位址

/**/ ///  

///   取出文字中的位址

///  

///   htmlstr

public static string getimgurl(string htmlstr)

");return str;

}#end region

java過濾html標籤函式

public static string html2text string inputstring string regex style s style s s s s style s 定義style的正規表示式 string regex html 定義html標籤的正規表示式 p script p...

Asp過濾指定html標籤函式

過濾指定html標籤 function lfilterbadhtml byval strhtml,byval strtags dim objregexp,stroutput dim arrtag,i arrtag split strtags,set objregexp new regexp stro...

js過濾HTML標籤

function removehtmltag str 第乙個 g 在js中正規表示式是以 開頭的,後面的 g,含義是表示全域性模式,意思是在將匹配的模式應用於整個字串,而不是在第一次匹配上之後就停止匹配了。這個分開來解釋,其中第二個字元 是乙個轉移字元,用來轉移後面的 字元的。匹配0或1個正好在它之...