3

I am using grepl in R, but I have a problem with it. When the string contains "+", it has an error. The error is shown below:

x <- "1.37E+11" 
grepl("1.37E+",x)  #TRUE
grepl("1.37E+11",x)  #FALSE
grepl("+11",x)  #TRUE
grepl("E+11",x)  #FALSE

When both in front of and after the + sign have words, the result is FALSE even though it should be TRUE. I am not sure why. Please help me. Thank you guys so much!! : )

ting_H
  • 83
  • 6
  • 1
    `+` is a reserved character meaning 1 or more in regular expressions. You can use `fixed = TRUE` in `grepl` which will escape that. – VvdL Sep 16 '22 at 16:01

0 Answers0