0

I have strings I have to replace, a ton of them exactly.

They have regular expressions in it:

to_replace <- c("Prop. D. Absatz Pack (w)", "Preis pro konv. Einh.", "Promopreis pro konv. Einh.")
replacing <- c("prop", "preis", "promo")

x <- c("Prop. D. Absatz Pack (w)", "test", "Promopreis pro konv. Einh.")

for (i in seq_along(to_replace)) {
    gsub(pattern = paste0("\\b", to_replace[i] , "\\b"), paste0("\\b", replacing[i], "\\b"), x)
}

It does not work unfortunately. Is there a way to use ALL of these . or ( as normal characters, not as regular expression? Thank you!

Data Mastery
  • 989
  • 3
  • 11
  • 31

0 Answers0