Java + JS去除網頁HTML標籤

同樣是工作上用到,在前(Javascript)、後端(Java、JSP)同樣都有的一個需求,就是必須將讀入的字串去除HTML Tag,以下是兩個範例:

var HTML = "";
HTML+= "<p>HTML P Tag String</p>";
HTML+= "<p><a href='/test/link.html'>HTML A Tag String</a></p>";

var htmlTagPattern = /<{1}[^>]{1,}>{1}/g; //HTML Tag Pattern
var htmlSplit = HTML.replace(htmlTagPattern, ""); //移除HTML Tag

console.log("htmlSplit : " , htmlSplit); //輸出htmlSplit :  HTML P Tag StringHTML A Tag String
package CDIT.stanley;
public class trimHTML {
	public static void main(String[] args) {
		String HTML = "";
		HTML+= "<p>HTML P Tag String</p>";
		HTML+= "<p><a href='/test/link.html'>HTML A Tag String</a></p>";
		
		String htmlTagPattern = "<{1}[^>]{1,}>{1}"; //HTML Tag Pattern		
		String htmlSplit = HTML.replaceAll(htmlTagPattern, ""); //移除HTML Tag
		
		System.out.println("htmlSplit : " + htmlSplit); //輸出htmlSplit : HTML P Tag StringHTML A Tag String
	}
}

You may also like...

24,550 Responses

  1. JohnniePaits表示:

    https://sildenafiliq.xyz/# sildenafil 50 mg price

  2. Isaacwem表示:

    Kamagra tablets: Kamagra 100mg price – Kamagra Oral Jelly

  3. RobertaRous表示:

    https://sildenafiliq.xyz/# generic sildenafil

  4. DanielElorp表示:

    Generic Viagra online buy viagra online Generic Viagra online

  5. ChesterAsynC表示:

    buy kamagra online usa: kamagra best price – sildenafil oral jelly 100mg kamagra

  6. DanielElorp表示:

    Cheap Viagra 100mg sildenafil iq Cheapest Sildenafil online

  7. RalphRem表示:

    http://kamagraiq.shop/# sildenafil oral jelly 100mg kamagra

  8. DanielElorp表示:

    cialis for sale cialis best price Buy Tadalafil 5mg

  9. ChesterAsynC表示:

    over the counter sildenafil: cheapest viagra – Viagra tablet online

  10. Isaacwem表示:

    sildenafil oral jelly 100mg kamagra: Sildenafil Oral Jelly – cheap kamagra

  11. RobertaRous表示:

    http://kamagraiq.shop/# Kamagra Oral Jelly

  12. RobertaRous表示:

    https://sildenafiliq.xyz/# Viagra online price

  13. ChesterAsynC表示:

    best price for viagra 100mg: buy viagra online – order viagra

  14. Isaacwem表示:

    Cheap Cialis: Generic Tadalafil 20mg price – Generic Tadalafil 20mg price

  15. JohnniePaits表示:

    http://tadalafiliq.shop/# Buy Cialis online

  16. DanielElorp表示:

    Cialis 20mg price in USA cialis without a doctor prescription Cheap Cialis

  17. RalphRem表示:

    http://sildenafiliq.com/# Viagra without a doctor prescription Canada

  18. DanielElorp表示:

    Buy Cialis online Buy Cialis online Cialis 20mg price

  19. RobertaRous表示:

    https://kamagraiq.com/# sildenafil oral jelly 100mg kamagra

  20. Isaacwem表示:

    Kamagra 100mg: Kamagra Oral Jelly Price – kamagra

  21. RalphRem表示:

    http://kamagraiq.com/# Kamagra 100mg

  22. RobertaRous表示:

    http://sildenafiliq.xyz/# sildenafil over the counter

  23. Isaacwem表示:

    Cheap generic Viagra: sildenafil iq – Viagra Tablet price

  24. DanielElorp表示:

    sildenafil online best price on viagra order viagra

  25. RobertaRous表示:

    https://sildenafiliq.xyz/# sildenafil 50 mg price

  26. DanielElorp表示:

    viagra without prescription buy viagra online Generic Viagra for sale

  27. Isaacwem表示:

    cheapest viagra: best price on viagra – buy viagra here

  28. RobertaRous表示:

    https://kamagraiq.com/# cheap kamagra

  29. DanielElorp表示:

    Tadalafil price cialis best price cheapest cialis

  30. RalphRem表示:

    http://sildenafiliq.com/# Buy generic 100mg Viagra online

發佈回覆給「DanielElorp」的留言 取消回覆

發佈留言必須填寫的電子郵件地址不會公開。