删除R中的两个连续转义字符之一

时间:2017-08-02 07:25:17

标签: r regex

我有以下句子,其中\ n出现字符

Get to 6 month rolling\nemail (from 13 months)\n\nOngoing work with Firm...

我需要删除连续两个中的一个,所以输出应该如下:

Get to 6 month rolling\nemail (from 13 months)\nOngoing work with Firm...

这样\ n \ n正在进行看起来像\ n正在进行中。在R中有什么简单的方法吗。非常感谢提前

1 个答案:

答案 0 :(得分:0)

这是

之一
> gsub("\n\n", "\n", "Get to 6 month rolling\nemail (from 13 months)\n\nOngoing work with Firm")
[1] "Get to 6 month rolling\nemail (from 13 months)\nOngoing work with Firm"