正則表達式過濾html標簽


1、說明:需要使用非貪婪模式

2、示例

過濾所有span標簽:

var newContent = Regex.Replace(htmlContent, "<span.*?>.*?</span>", String.Empty);

過濾所有具有某個class=Text的span

var newContent= Regex.Replace(testStr, "<span class=\"Text\".*?>.*?</span>", String.Empty);

3、舉一反三,同理可以過濾掉div、a、tr、等html標簽。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM