Skip to content

Commit

Permalink
Add method removeHtmlAttr
Browse files Browse the repository at this point in the history
  • Loading branch information
looly committed Sep 9, 2014
1 parent 676d2b2 commit 0ec4440
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 @@ -129,6 +129,21 @@ public static String removeHtmlTag(String content, boolean withTagContent, Strin
return content;
}

/**
* 去除HTML标签中的属性
* @param content 文本
* @param attrs 属性名(不区分大小写)
* @return 处理后的文本
*/
public static String removeHtmlAttr(String content, String... attrs) {
String regex = null;
for (String attr : attrs) {
regex = StrUtil.format("(?i)\\s*{}=[\"'].*?[\"']", attr);
content = content.replaceAll(regex, StrUtil.EMPTY);
}
return content;
}

/**
* Encoder.
*/
Expand Down

0 comments on commit 0ec4440

Please sign in to comment.