This question was seeking a similar answer probably before stringr::str_replace_all had that option (or was well known). I\'m copying the gist of my answer belo
stringr::str_replace_all