(Skip) (Fail) Error parsing with stringi

I read / studied the biggest Regex Ever trick where we say we want something other than ... using (*SKIP)(*FAIL). OK, so I took it for rotation on the example of toys below, and it works in the R database, but has the following error in stringi . Do I need to do something different with stringi to make the syntax work?

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)
+4
source share
1 answer

The module stringi(s stringr) are bundled with the ICU regular expression library and (*SKIP)(*FAIL)verbs are not supported (they are actually supported only by the PCRE library).

ou, h l, :

(?<!h)ou(?!l)

regex

> x <- c("I shouldn't", "you should", "I know", "'bout time")
> pat1 <- "(?<!h)ou(?!l)"
> stringi::stri_detect_regex(x, pat1)
[1] FALSE  TRUE FALSE  TRUE

Lookahead Lookbehind.

, ICU lookbehind , lookbehind . , stringi, , ou, s - ,

> pat2 <- "(?<!s\\w{0,100})ou"
> stringi::stri_detect_regex(x, pat2)
[1] FALSE  TRUE FALSE  TRUE

(?<!s\\w{0,100}) lookbehind , ou s, 0 100 - .

0

Source: https://habr.com/ru/post/1624358/


All Articles