Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何转换字符串
"<br><br><br><br><br><br>" to "<br>" using java's String.replaceAll(String, String) method?
我都试过了:
str.replaceAll("<br>+","<br>"); str.replaceAll("<br>{1,}","<br>);
但两者都不起作用。
<br>+匹配"<br>>>>>>>>",试试这个:(<br>)+
<br>+
"<br>>>>>>>>"
(<br>)+
如果标签之间有空格,请执行以下操作:
str = str.replaceAll("(<br>\\s*)+","<br>");