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,736 Responses

  1. Michaeltaisa表示:

    https://amoxil.icu/# can i buy amoxicillin over the counter

  2. Danielnek表示:

    https://amoxil.icu/# how to get amoxicillin over the counter

  3. MichaelSom表示:

    can i purchase generic clomid online: cost of generic clomid – where to buy cheap clomid

  4. Antoniobus表示:

    https://ciprofloxacin.life/# cipro 500mg best prices

  5. Antoniobus表示:

    http://ciprofloxacin.life/# ciprofloxacin 500mg buy online

  6. MichaelSom表示:

    can you buy generic clomid without prescription: how to get cheap clomid without insurance – how to get cheap clomid tablets

  7. Danielnek表示:

    https://amoxil.icu/# amoxicillin in india

  8. JasonWaync表示:

    antibiotics cipro: buy ciprofloxacin over the counter – ciprofloxacin generic

  9. Stephenbum表示:

    https://clomid.site/# can i order generic clomid pill

  10. AndrewRex表示:

    price of amoxicillin without insurance: amoxicillin for sale online – how to get amoxicillin over the counter

  11. WillianSeEmO表示:

    amoxacillian without a percription amoxicillin 50 mg tablets amoxicillin cephalexin

  12. Hermanges表示:

    amoxicillin buy canada generic amoxicillin online amoxicillin 500 mg without prescription

  13. GeorgeEteli表示:

    amoxicillin buy no prescription: amoxicillin 500 mg online – where can i buy amoxicillin over the counter uk

  14. Raymondsmero表示:

    https://clomid.site/# how to get generic clomid pill

  15. Hermanges表示:

    paxlovid covid paxlovid india buy paxlovid online

  16. JasonWal表示:

    prednisone in uk: prednisone cost 10mg – cortisol prednisone

  17. JasonWal表示:

    buy amoxicillin: cost of amoxicillin 875 mg – buy amoxicillin 500mg

  18. Hermanges表示:

    where to get generic clomid price how to buy clomid clomid online

  19. JasonWal表示:

    where can i buy amoxicillin online: amoxicillin from canada – buy amoxicillin online with paypal

  20. Raymondsmero表示:

    http://amoxil.icu/# amoxil pharmacy

  21. JasonWal表示:

    Paxlovid buy online: paxlovid india – paxlovid buy

  22. JasonWal表示:

    where to buy amoxicillin 500mg: amoxicillin 500 mg brand name – amoxicillin 500 mg without a prescription

  23. JasonWal表示:

    get clomid: where buy clomid for sale – where to get generic clomid online

  24. Hermanges表示:

    paxlovid buy paxlovid india paxlovid pill

  25. JasonWal表示:

    cost of generic clomid pill: order cheap clomid – can you buy cheap clomid now

  26. JasonWal表示:

    can i order generic clomid: buy cheap clomid prices – clomid rx

  27. BrianDutle表示:

    http://clomid.site/# get generic clomid

  28. JasonWal表示:

    buy amoxicillin 500mg canada: amoxicillin order online – over the counter amoxicillin canada

  29. Raymondsmero表示:

    http://ciprofloxacin.life/# cipro ciprofloxacin

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

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