Created
June 20, 2019 02:18
-
-
Save icella/98ed543be9babc0ca506d547e6722296 to your computer and use it in GitHub Desktop.
去掉字符串中的html标签的正则表达式
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//定义script的正则表达式,去除js可以防止注入 | |
String scriptRegex="<script[^>]*?>[\\s\\S]*?<\\/script>"; | |
//定义style的正则表达式,去除style样式,防止css代码过多时只截取到css样式代码 | |
String styleRegex="<style[^>]*?>[\\s\\S]*?<\\/style>"; | |
//定义HTML标签的正则表达式,去除标签,只提取文字内容 | |
String htmlRegex="<[^>]+>"; | |
//定义空格,回车,换行符,制表符 | |
String spaceRegex = "\\s*|\t|\r|\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment