str1 <- "I don't know 'how' to remove these ' things"gsub("\\s*'\\B|\\B'\\s*", "", str1)
Standard input is empty
[1] "I don't know how to remove these things"
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!