過(guò)濾html
string regEx_style = "<style[^>]*?>[\\s\\S]*?<\\/style>"; //定義style的正則表達(dá)式? ? string regEx_script = "<script[^>]*?>[\\s\\S]*?<\\/script>"; //定義script的正則表達(dá)式? ? ? string regEx_html = "<[^>]+>"; //定義HTML標(biāo)簽的正則表達(dá)式? ? ? htmlStr = Regex.Replace(htmlStr, regEx_style, "");//刪除css? ? htmlStr = Regex.Replace(htmlStr, regEx_script, "");//刪除js? ? htmlStr = Regex.Replace(htmlStr, regEx_html, "");//刪除html標(biāo)記? ? htmlStr = Regex.Replace(htmlStr, "\\s*|\t|\r|\n", "");//去除tab、空格、空行? ? htmlStr = htmlStr.Replace(" ", "");? ? htmlStr = htmlStr.Replace(""", "");//去除異常的引號(hào)" " "? ? htmlStr = htmlStr.Replace(""", "");? ? return htmlStr.Trim();