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 } }
https://k8viet.guru/# nha cai k8
k8 th? dam: link vao k8 – k8vip
https://alo789.auction/# alo789
alo789in: alo 789 – alo 789 dang nh?p
https://alo789.auction/# alo789 chinh th?c
https://88betviet.pro/# nha cai 88bet
link vao k8 k8vip k8 bet
http://alo789.auction/# 789alo
https://88betviet.pro/# 88bet slot
http://88betviet.pro/# 88bet
k8 th? dam: link vao k8 – nha cai k8
https://alo789.auction/# alo789in
k8 bet: k8 th? dam – k8
88bet 88bet 188bet 88bet
https://88betviet.pro/# 188bet 88bet
nha cai k8 k8 bet k8
nha cai 88bet: 88bet slot – 88bet slot
k8 bet k8 th? dam k8 bet
alo789in: alo 789 dang nh?p – alo789 chinh th?c
http://88betviet.pro/# keo nha cai 88bet
http://alo789.auction/# alo789
nha cai k8: nha cai k8 – k8
https://k8viet.guru/# k8 th? dam
http://k8viet.guru/# k8 bet
https://88betviet.pro/# 88bet slot
https://alo789.auction/# alo 789
https://k8viet.guru/# k8 bet
alo789in: alo 789 – alo789hk
alo 789 dang nh?p: alo789 dang nh?p – alo789
http://alo789.auction/# alo789in