我正在阅读/学习The Greatest Regex Trick Ever我们说我们想要一些东西,除非......使用(*SKIP)(*FAIL)
. 好的,所以我在下面的玩具示例中使用了它,它在基础 R 中工作,但在stringi中有以下错误。我是否需要对stringi做一些不同的事情才能使语法正常工作?
x <- c("I shouldn't", "you should", "I know", "'bout time")
pat <- '(?:houl)(*SKIP)(*FAIL)|(ou)'
grepl(pat, x, perl = TRUE)
## [1] FALSE TRUE FALSE TRUE
stringi::stri_detect_regex(x, pat)
## Error in stringi::stri_detect_regex(x, pat) :
## Syntax error in regexp pattern. (U_REGEX_RULE_SYNTAX)