问题
I am trying to remove all "H" within the strings, EXCEPT the ones including "CH" in the following example:
strings <- c("Cash","Wishes","Chain","Chip","Check")
I found that the code below remove only "H"
data<- gsub("H", "", strings)
回答1:
You can do this with a negative look-behind.
gsub("(?<!c)h", "", strings, perl=TRUE, ignore.case = TRUE)
来源:https://stackoverflow.com/questions/47538826/removing-all-h-within-the-strings-except-the-ones-including-ch