【发布时间】:2018-05-15 14:17:29
【问题描述】:
我正在尝试从下面的字符串中删除括号。
library(stringr)
x <- "(Verhoeff,1937)"
str_replace(string = x, pattern = "(\\()|(\\))", replacement = "")
[1] "Verhoeff,1937)"
gsub(pattern = "(\\()|(\\))", replacement = "", x = x)
[1] "Verhoeff,1937"
str_replace 似乎没有找到右括号?
任何想法为什么?
【问题讨论】:
-
sub≈str_replace;gsub≈str_replace_all(“g”代表“全局”)。 -
感谢您的澄清。
标签: r string replace gsub stringr