[\sb,\sc] means "one character in the middle of a space, b ,,, space, c ". You probably want something like (\sb|\sc) , which means "space followed by b , or space followed by c " or \s[bc] , which means "space followed by b or c . "
s <- "ab b cde" gsub( "(\\sb|\\sc)", " ", s, perl=TRUE ) gsub( "\\s[bc]", " ", s, perl=TRUE ) gsub( "[[:space:]][bc]", " ", s, perl=TRUE ) # No backslashes
To delete multiple letter instances (as in the second example), enable + after deleting the letter.
s2 <- "akui i ii" gsub("\\si+", " ", s2)
source share