I am trying to remove brackets from a string like the one below.
library(stringr) x <- \"(Verhoeff,1937)\" str_replace(string = x, pattern = \"(\\\\()|(
It only matches the first occurency, whereas gsub does it all. Use str_replace_all instead:
gsub
str_replace_all
str_replace(string = "aa", pattern = "a", replacement = "b") # only first str_replace_all(string = "aa", pattern = "a", replacement = "b") # all