I need a simple regex that will remove all line breaks after comma. right know what I'm doing is removing all
\n/g
what do I need to add in order to remove only after comma? thanks.
Use
replace(/,\n/g,"")
For example
"\n\n,\n".replace(/,\n+/g,",")
That's really simple. Try this:
/,\n+/g
Full Code:
var str = "first line,\nsecond line,\nalso, it is third line,\nand fourth line";
str = str.replace(/,\n+/g, ',');
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.