小编Bra*_*gen的帖子

R - 当在以破折号结尾的“单词”上使用单词边界时,为什么 str_detect 返回与 grepl 不同的结果

str_detect 的帮助页面指出“相当于 grepl(pattern, x)”,但是:

str_detect("ALL-", str_c("\\b", "ALL-", "\\b"))
[1] FALSE
Run Code Online (Sandbox Code Playgroud)

尽管

grepl(str_c("\\b", "ALL-", "\\b"), "ALL-")
[1] TRUE
Run Code Online (Sandbox Code Playgroud)

我想其中之一没有按预期工作?或者我错过了什么?

regex r str-replace stringr

5
推荐指数
1
解决办法
339
查看次数

标签 统计

r ×1

regex ×1

str-replace ×1

stringr ×1