fork download
  1. x <- c('This is a simple text', 'this is a veryyyyyyyyyy long word', 'Replacethis andalsothis')
  2. gsub("\\b(\\w{10})\\B", "\\1 ", x)
  3. # => [1] "This is a simple text" "this is a veryyyyyyy yyy long word" "Replacethi s andalsothi s"
  4.  
  5. x <- c("this is a veryyyyyyy|yyy long word")
  6. gsub("(?<!\\S)(\\S{10})(?=\\S)", "\\1 ", x, perl=TRUE)
  7. # => [1] "this is a veryyyyyyy |yyy long word"
Success #stdin #stdout 0.23s 39020KB
stdin
Standard input is empty
stdout
[1] "This is a simple text"              "this is a veryyyyyyy yyy long word"
[3] "Replacethi s andalsothi s"         
[1] "this is a veryyyyyyy |yyy long word"