You can use the PCRE regular expression with negative lookbehind and lookahead:
j <- "Abc,Abc, and c" gsub("(?<!\\s),(?!\\s)", " ", j, perl = TRUE) ## => [1] "Abc Abc, and c"
Watch the regex demo
More details
(?<!\\s) - there should be no spaces immediately before ,, - letter(?!\\s) - there can be no space immediately after ,
An alternative solution is to compare with,, enclosed with layers:
j <- "Abc,Abc, and c" gsub("\\b,\\b", " ", j)
See another demo of R.
source share