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

16,393 Responses

  1. DavidBaide表示:

    buying prescription drugs in mexico https://mexicanpharmgate.com/ mexico pharmacies prescription drugs

  2. 15 Secretly Funny People Working In Male Masturbators Buy Male masturbators

  3. Dereketerm表示:

    rexall pharmacy amoxicillin 500mg: com pharm – rexall pharmacy amoxicillin 500mg

  4. link dola4d表示:

    Ridiculous quest there. What occurred after? Thanks!

  5. BrandenSlomy表示:

    where can i buy amoxicillin online: com pharm – over the counter amoxicillin

  6. StevenNub表示:

    buy priligy: dapoxetine online – max pharm

  7. StevenNub表示:

    buy amoxil: amoxil – where can i get amoxicillin 500 mg

  8. StevenNub表示:

    amoxicillin 500 mg cost: amoxil com pharm – buy amoxicillin over the counter uk

  9. StevenNub表示:

    buy prednisone online no prescription: Prednisone Without Prescription – prednisone 20mg price in india

  10. BrandenSlomy表示:

    rexall pharmacy amoxicillin 500mg: Com Pharm – amoxicillin 500 mg without prescription

  11. Dereketerm表示:

    can i buy clomid without rx: rex pharm – buy clomid without prescription

  12. BrandenSlomy表示:

    buy priligy: priligy max pharm – priligy max pharm

  13. Dereketerm表示:

    cost generic clomid without dr prescription: clomid – where to get clomid prices

  14. BrandenSlomy表示:

    canadian pharmacy amoxicillin: Amoxicillin for sale – amoxicillin without a prescription

  15. StevenNub表示:

    prednisone 80 mg daily: prednisone – prednisone 1 tablet

  16. StevenNub表示:

    how to buy clomid without rx: clomid online – where can i get clomid pill

  17. StevenNub表示:

    cheap priligy: dapoxetine price – dapoxetine price

  18. StevenNub表示:

    Priligy tablets: max pharm – buy priligy max pharm

  19. Dereketerm表示:

    buy dapoxetine online: cheap priligy – Priligy tablets

  20. Dereketerm表示:

    20 mg prednisone tablet: buy prednisone – prednisone for sale

  21. StevenNub表示:

    dapoxetine online: max pharm – dapoxetine online

  22. BrandenSlomy表示:

    prednisone 20mg tab price: Prednisone Without Prescription – prednisone where can i buy

  23. BrandenSlomy表示:

    can i buy amoxicillin over the counter: amoxil com pharm – amoxicillin 500 mg purchase without prescription

  24. BrandenSlomy表示:

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

  25. StevenNub表示:

    prednisone 30 mg tablet: prednisone ray pharm – prednisone 10 mg

  26. Dereketerm表示:

    prednisone 10mg: where to buy prednisone 20mg no prescription – buy prednisone 10mg

  27. StevenNub表示:

    Priligy tablets: priligy maxpharm – dapoxetine price

  28. Dereketerm表示:

    buy priligy max pharm: buy priligy max pharm – max pharm

  29. StevenNub表示:

    cost of prednisone tablets: prednisone – 5 mg prednisone tablets

發佈留言

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