I am trying to replace the string as shown below. But it is getting duplicated. Can anyone help here
str_replace("A Bring home",c("Bring","home"), c("NEW Bring",'NEW Home'))
[1] "A NEW Bring home" "A Bring NEW Home"
Expected output
str_replace("A Bring home",c("Bring","home"), c("NEW Bring",'NEW Home'))
[1] "A NEW Bring NEW Home"
As per below suggestions, I tried one example below
reduce2(c("This is the link https://google.com also there is another link, https://yahoo.com This is the link https://google.com"), c("<a href=https://google.com>Click here</a>","<a href=https://yahoo.com>Click here</a>", "<a href=https://google.com>Click here</a>"), .init = "This is the link https://google.com also there is another link, https://yahoo.com This is the link https://google.com", str_replace)
Output I am getting
This is the link Click here>Click here also there is another link, Click here This is the link https://google.com
Expected ouput
This is the link Click here also there is another link, Click here This is the link Click here