0

I'm trying to find all the set of strings with two consecutive repeated words like "the the", "air air". I'm using grepl function in R and my code look like this:

grepl("[a-zA-Z]+\\s+\1", c("the the", "Humbert Humbert", "air water"), perl = TRUE)

[1] FALSE FALSE FALSE

The strings "the the" and "air air" should return TRUE but it returns FALSE which is I don't know why.

Is there anything missing in my code? Please help me.

lmo
  • 37,904
  • 9
  • 56
  • 69

0 Answers0