Closed krlmlr closed 7 years ago
Rex generates PCRE which support escaping characters inside character classes not POSIX regular expressions, which do not [1]. This is one of the reasons re_matches()
sets perl = TRUE
when it calls gregexpr()
and regexpr()
.
library(rex)
rx <- rex(none_of("]"))
rx
#> [^\]]
grepl(rx, "]", perl = T)
#> [1] FALSE
grepl(rx, "a", perl = T)
#> [1] TRUE
re_matches("]", rx)
#> [1] FALSE
re_matches("a", rx)
#> [1] TRUE
Thanks for clarifying.
has a useless backslash. The closing bracket
]
needs to be first after^
, without backslash.Tested with b037a54.