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...

26,752 Responses

  1. Jamesarill表示:

    http://doxycyclinebestprice.pro/# doxycycline 100mg

  2. BobbyPem表示:

    http://nolvadex.fun/# clomid nolvadex

  3. Brandonjat表示:

    doxycycline without prescription doxycycline medication doxycycline without a prescription

  4. DavidFrels表示:

    п»їcytotec pills online: cytotec online – buy cytotec in usa

  5. DavidFrels表示:

    benicar lisinopril: zestril 20 mg price – lisinopril 20 mg discount

  6. BobbyPem表示:

    http://cytotec.icu/# buy cytotec in usa

  7. DavidFrels表示:

    tamoxifen rash: tamoxifen and osteoporosis – tamoxifen dosage

  8. StevenZen表示:

    vibramycin 100 mg: 100mg doxycycline – generic for doxycycline

  9. Brucevaf表示:

    lisinopril 40 mg brand name: lisinopril 20 mg generic – lisinopril brand name canada

  10. Brandonjat表示:

    zithromax 500 mg lowest price pharmacy online zithromax cost cheap zithromax pills

  11. Timothyket表示:

    ordering prednisone: buy prednisone nz – prednisone price

  12. Timothyket表示:

    prednisone buy online nz: prednisone 10 mg price – cost of prednisone in canada

  13. MichaelSom表示:

    where can i buy generic clomid: can i buy cheap clomid online – how to get clomid pills

  14. Michaeltaisa表示:

    http://amoxil.icu/# amoxicillin 875 125 mg tab

  15. Antoniobus表示:

    http://ciprofloxacin.life/# where can i buy cipro online

  16. Timothyket表示:

    prednisone 300mg: prednisone 50 mg tablet canada – how much is prednisone 5mg

  17. MichaelSom表示:

    where buy clomid without insurance: generic clomid without insurance – order clomid tablets

  18. MichaelWence表示:

    get cheap clomid pills where buy clomid without dr prescription – clomid without rx

  19. MichaelWence表示:

    can i order generic clomid where buy clomid without a prescription – can i get clomid without prescription

  20. MichaelWence表示:

    can i purchase generic clomid tablets how to get cheap clomid for sale – where to buy generic clomid without a prescription

  21. Danielnek表示:

    https://amoxil.icu/# where can i buy amoxocillin

  22. Michaeltaisa表示:

    https://amoxil.icu/# amoxil generic

  23. Antoniobus表示:

    https://ciprofloxacin.life/# ciprofloxacin generic

  24. Timothyket表示:

    prednisone for sale without a prescription: prednisone buy cheap – prednisone 0.5 mg

  25. MichaelSom表示:

    where to buy cheap clomid prices: how to buy cheap clomid tablets – where can i get clomid now

  26. MichaelWence表示:

    clomid for sale can i purchase cheap clomid without rx – cost generic clomid without a prescription

  27. Timothyket表示:

    prednisone 10mg tabs: prednisone 40 mg tablet – prednisone online sale

  28. Michaeltaisa表示:

    http://amoxil.icu/# buy amoxil

  29. MichaelWence表示:

    buying generic clomid prices buying generic clomid – can i purchase generic clomid prices

  30. Danielnek表示:

    http://amoxil.icu/# amoxicillin cost australia

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

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