#3
(.)\1\1 - Should this read “(.)\1\” ? This would repeat a character three times.
“(.)(.)\2\1” - This would repeat two characters twice and then reverse.
(..)\1 - This would repeat two characters twice.
“(.).\1.\ 1” - This would repeat two characters three times.
“(.)(.)(.).*\3\2\1” - This would call three characters and then reverse it.
#4
Start and end with the same character
words <- c("racecar", "america", "radar")
find <- str_detect(words, "^(.).*\\1$")
find
## [1] TRUE TRUE TRUE
Contain a repeated pair of letters (e.g. “church” contains “ch” repeated twice.)
repeats <- c("church", "coco", "perpendicular")
search <- str_detect(repeats, "(..).*\\1")
search
## [1] TRUE TRUE TRUE
Contain one letter repeated in at least three places (e.g. “eleven” contains three “e”s.)
three <- c("mirror", "terror", "rearrange")
lookup <- str_detect(three, "(.)(^\\1)*\\1(^\\1)*\\1")
lookup
## [1] FALSE FALSE FALSE