I've got a regex .replaceAll("(\\r\\n|\\n)", "< br />"));
which replaces all \\n
and replaces with < br/>
.
The thing I wanted here, is to replace more than one \\n
in a row by only one < br/>
What would be a regex for that?
添加+
量词,表示“一个或多个”:
.replaceAll("(\r?\n)+", "<br />"));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.