Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当我运行以下 4 行代码时,我没有从所有 4 行中得到相同的结果。为什么最后一行没有找到匹配项?
grep("CPA's", c("CPA's")) agrep("CPA's", c("CPA's")) grep("CPA'?s?", c("CPA's")) agrep("CPA'?s?", c("CPA's"))
我还没有完整阅读模糊匹配函数,但从表面上看,我不明白为什么这会是一个问题。
因为差异大于默认值max.distance0.1。增加max.distance它,它将捕获它。
max.distance
agrep("CPA'?s?", "CPA's", max.distance = 0.15) #[1] 1
要将模式视为正则表达式,请选择fixed = FALSE将直接起作用的模式
fixed = FALSE
agrep("CPA'?s?", "CPA's", fixed = FALSE)