【发布时间】:2019-02-19 16:35:57
【问题描述】:
我怎样才能删除每一个双换行符,只有一个?
var string = "this is a ↵↵↵↵ test there will ↵↵ be more ↵↵↵↵ newline characters"
类似的东西
var string = "this is a ↵↵ test there will ↵ be more ↵↵ newline characters"
我已经尝试过了,但这会替换所有新行,我想保留单行
string.replace(/[\n\n]/g, '')
【问题讨论】:
-
删除
[...] -
抱歉,这个 [...] 是什么意思?编辑:我明白你的意思是正则表达式中的括号,我正在尝试!非常感谢!
标签: javascript replace newline