fork download
  1. library(stringr)
  2. s <- "-+?="
  3. str_replace_all(s, "([\\p{P}\\p{S}])(?=[\\p{P}\\p{S}])", "\\1 ")
  4. str_replace_all(s, "(?<=[\\p{P}\\p{S}])(?=[\\p{P}\\p{S}])", " ")
  5. gsub("(?<=[[:punct:]])(?=[[:punct:]])", " ", s, perl=TRUE)
Success #stdin #stdout 0.3s 42860KB
stdin
Standard input is empty
stdout
[1] "- + ? ="
[1] "- + ? ="
[1] "- + ? ="