/**
* 剔除结尾的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 -
Java去除字符串中结尾的所有br标签
最新推荐文章于 2023-07-11 15:26:47 发布