fork download
  1. text <- "are blue and then and then more and then and then more very bright"
  2. gsub("(?s)(\\b.+?\\b)\\1\\b", "\\1", text, perl=T) ## shorter repeated substrings
  3. gsub("(?s)(\\b.+\\b)\\1\\b", "\\1", text, perl=T) ## longer repeated substrings
Success #stdin #stdout 0.45s 79168KB
stdin
Standard input is empty
stdout
[1] "are blue and then more and then more very bright"
[1] "are blue and then and then more very bright"