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>");