相关疑难解决方法(0)

计算字符串中"("的出现次数

我试图在R中的字符串中获取开括号的数量.我正在使用包中的str_count函数stringr

s<- "(hi),(bye),(hi)"
str_count(s,"(")
Run Code Online (Sandbox Code Playgroud)

stri_count_regex出错(string,pattern,opts_regex = attr(pattern,:`正则表达式模式中的嵌套括号错误.(U_REGEX_MISMATCHED_PAREN)

我希望这个例子得到3

r stringr

14
推荐指数
2
解决办法
1万
查看次数

标签 统计

r ×1

stringr ×1