specific simple one how exact create characters regex r stringr

simple - Regex patrón múltiple con reemplazo singular



regex specific characters (2)

Estoy tratando de reemplazar tanto "st". y "ste". con "st". Parece que lo siguiente debería funcionar pero no lo hace:

require("stringr") county <- c("st. landry", "ste. geneveve", "st. louis") str_replace_all(county, c("st//.", "ste//."), "st")


Puede utilizar | significar "o"

> str_replace_all(county, "st//.|ste//.", "st") [1] "st landry" "st geneveve" "st louis"

O en la base R

> gsub("st//.|ste//.", "st", county) [1] "st landry" "st geneveve" "st louis"


> A<-"this string, contains a handful of, useless: punctuation. Some are to escape. Aaargh! Some might be needed, but I want none!" > gsub(", |: |//. |!","",A) [1] "this string contains a handful of useless punctuation Some are to escape Aaargh Some might be needed but I want none"