Skip to content
Prev 383498 / 398502 Next

regular expression, stringr::str_view, grep

This highlights the literal meaning of the last ] in your correct_brackets:

aff <- c("affgfk]ing", "fgok", "rafgkah]e","a fgk", "bafghk]")

To me, too, the missing_brackets looks more like what was desired, and
returns correct results for a PCRE. Perhaps the regular expression
should have been rewritten:

desired_brackets <- "af+g[^m$][^A-Z]"
grep(desired_brackets, aff, value = TRUE) ### correct result
str_view(aff, desired_brackets) ### correct result

Regards,
Andy
On 28.04.2020 18:41:50, David Winsemius wrote: