fork download
  1. x <- "I'm dash before word -word, dash &%$,. in-between word, two before word --word just dashes ------, between words word - word"
  2. gsub("\\b([-'])\\b|[[:punct:]]+", "\\1", x, perl=TRUE)
  3. # => "I'm dash before word word dash in-between word two before word word just dashes between words word word"
  4.  
Success #stdin #stdout 0.21s 39608KB
stdin
Standard input is empty
stdout
[1] "I'm dash before word word dash  in-between word two before word word just dashes  between words word  word"