I'm trying to remove linebreaks if there are no characters next to it.
I'd like to keep Line1, Line2, Line3 untouched but the break after Line3 and before Line1 removed.
I tried:
Element.value = Element.value.replace(/\n?![A-z]/g, "");
I'm not too good with regex.
Thanks.
.replace(/(\r?\n){2,}/g, '\n').replace(/^\r?\n|\r?\n$/g, '');
This regex replaces sequences of 2 or more line breaks with a single line break, then remove leading and trailing line breaks.
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.