【发布时间】:2015-08-25 15:22:16
【问题描述】:
在 R 中,我可以使用 \\1 来引用捕获组。但是,当使用 stringi 包时,这并没有按预期工作。
library(stringi)
fileName <- "hello-you.lst"
(fileName <- stri_replace_first_regex(fileName, "(.*)\\.lst$", "\\1"))
[1] "1"
预期输出:hello-you。
在the documentation 我找不到任何关于这个问题的信息。
【问题讨论】:
-
从文档 (
?stri_replace_first_regex) 中将\\1更改为$1:引用的格式为 $n,其中 n 是捕获组的编号(它们的编号从 1 开始)。
标签: r backreference stringi