Reputation: 2521
I have the following regular expression in an R script:
grepl("\xe9", "MY TEXT", fixed = FALSE, ignore.case = TRUE, perl = FALSE)
I get the following error:
Error in grepl("\xe9", "MY TEXT", fixed = FALSE, ignore.case = TRUE, :
regular expression is invalid in this locale
"\xe9" is unicode representation of "é" and is read as-is from a file.
How can I fix this? Additionally, is there a useful resource on locales w.r.t regular expression in R?
Upvotes: 2
Views: 1936
Reputation: 263411
I don't know why @joran didn't just post this as an answer:
grepl("\\xe9", c("MY TEXT", "é"), fixed = FALSE, ignore.case = TRUE, perl = FALSE)
#[1] FALSE TRUE
Upvotes: 4