Skip to content

Commit

Permalink
Add method removeAllHtmlAttr
Browse files Browse the repository at this point in the history
  • Loading branch information
looly committed Sep 9, 2014
1 parent 0ec4440 commit b0ce9a7
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main/java/com/xiaoleilu/hutool/HtmlUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,21 @@ public static String removeHtmlAttr(String content, String... attrs) {
return content;
}

/**
* 去除指定标签的所有属性
* @param content 内容
* @param tagNames 指定标签
* @return
*/
public static String removeAllHtmlAttr(String content, String... tagNames) {
String regex = null;
for (String tagName : tagNames) {
regex = StrUtil.format("(?i)<{}[^>]*?>", tagName);
content.replaceAll(regex, StrUtil.format("<{}>", tagName);
}
return content;
}

/**
* Encoder.
*/
Expand Down

0 comments on commit b0ce9a7

Please sign in to comment.