Je voudrais remplacer une partie d'une chaîne de caractères, mais je veux que la correspondance soit exacte. Dans le cas ci-dessous, je veux que ABC soit remplacé par mytag et non que A soit remplacé par mytag, etc.
mytags <- c("A","AB","ABC","B","BB","BBC","C","CB","CBC")
x <- "I would like to replace ABC with mytag"
stri_replace_all_fixed(x,mytags,"mytag", vectorize_all=TRUE)
[1] "I would like to replace mytagBC with mytag" "I would like to replace mytagC with mytag" "I
would like to replace mytag with mytag"
[4] "I would like to replace AmytagC with mytag" "I would like to replace ABC with mytag" "I
would like to replace ABC with mytag"
[7] "I would like to replace ABmytag with mytag" "I would like to replace ABC with mytag" "I
would like to replace ABC with mytag"
Ce que j'aimerais obtenir est :
[1] "I would like to replace mytag with mytag"