/**
* 剔除结尾的br-正则
* @param cs 字符序列
* @return 删除html标签后的字符序列
*/
public static String replaceEndBrHtml(String cs){
String rex = "^(.*)(<br/?>)$";
Pattern comPile = Pattern.compile(rex);
Matcher matcher = comPile.matcher(cs);
while(matcher.find()){
cs = matcher.group(1);
matcher = comPile.matcher(cs);
}
return cs;
}
/**
* 删除结尾的br
* @param cs 字符序列
* @return 删除html标签后的字符序列
*/
public static String deleteEndBrHtml(String cs){
if(isEmpty(cs)){
return "";
}
String s2 = cs.replaceAll("<br>", "~").replaceAll("<br/>", "~");
if(s2.lastIndexOf("\"")>0){
s2 = s2.substring(0,s2.length()-1);
}
int len = s2.length();
int st = 0;
char[] val = s2.toCharArray();
while ((st < len) && (val[len - 1] == '~')) {
len--;
}
String s3 = ((st > 0) || (len < s2.length())) ? s2.substring(st, len) : s2;
String s4 = s3.replaceAll("~", "<br>");
return s4;
}
/**
* 删除所有br
* @param cs 字符序列
* @return 删除html标签后的字符序列
*/
public static String deleteNotBrHtml(CharSequence cs){
if(isEmpty(cs)){
return "";
}
return Pattern.compile("<br([^>]*)>").matcher(cs).replaceAll("").replaceAll("</br>","");
}
문자열의 자바 끝은 모든 레이블 BR 제거하는
추천
출처blog.csdn.net/Smile_Sunny521/article/details/97258919
추천
행