我正在尝试使用 stringi 替换某些单词stri_replace
,但是在替换单词的相似部分时遇到了问题。在下面的示例中,我正在修复三角形的拼写错误,但它似乎变得混乱,因为 'tri' 是 'trian' 的一部分,是 'triangle' 的一部分,它就像 'trainglegle'。我不太熟悉stri_replace
,有什么我遗漏的论点吗?谢谢你的帮助。
stri_replace_all_regex("The quick brown tri jumped over the lazy trian.",
c("tri", "trian", "fox"), c("triangle", "triangle", "bear"),
vectorize_all=FALSE)
## [1] "The quick brown trianglegle jumped over the lazy triangleglean."