Skip to content

Instantly share code, notes, and snippets.

View jackzhao29's full-sized avatar

coldface jackzhao29

View GitHub Profile
@jackzhao29
jackzhao29 / default.java
Created September 18, 2017 03:02 — forked from binjoo/default.java
JAVA:清除HTML标签
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class HTMLSpirit{
public static String delHTMLTag(String htmlStr){
String regEx_script="<script[^>]*?>[\\s\\S]*?<\\/script>"; //定义script的正则表达式
String regEx_style="<style[^>]*?>[\\s\\S]*?<\\/style>"; //定义style的正则表达式
String regEx_html="<[^>]+>"; //定义HTML标签的正则表达式
Pattern p_script=Pattern.compile(regEx_script,Pattern.CASE_INSENSITIVE);