[英]Javascript regex remove all line breaks after comma
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, ',');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.