gagolews / stringi

Fast and portable character string processing in R (with the Unicode ICU)
https://stringi.gagolewski.com/
Other
304 stars 44 forks source link

Syntax error in regex pattern. #455

Closed ycphs closed 3 years ago

ycphs commented 3 years ago

A regex expression to get the content in brackets

stri_extract_all_regex(V2, "(?<=\\()+.+?(\\))")

resulted in the following error:

Error in stri_extract_all_regex(V2, "(?<=\()+.+?(\))") : Syntax error in regex pattern. (U_REGEX_RULE_SYNTAX, context=(?<=\()+.+?(\)))

I checked the expression here: regex check

The following command works perfect.

stri_extract_all_regex(V2,"(\\()+.+?(\\))")

it seems that the lookahead (positive and negative) doesn't work.

gagolews commented 3 years ago

There is a syntax error in your regex.

You cannot have a quantifier + applied on a look-behind assertion.

Consult the ICU regex syntax at https://unicode-org.github.io/icu/userguide/strings/regexp.html.