去除所有“ H”。在字符串中,除了包含“ CH”的字符串 [英] Removing all "H" within the strings, EXCEPT the ones including "CH"
本文介绍了去除所有“ H”。在字符串中,除了包含“ CH”的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在以下示例中,我尝试删除字符串中的所有 H,但包括 CH的除外:
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")
我发现下面的代码仅删除 H
I found that the code below remove only "H"
data<- gsub("H", "", strings)
推荐答案
负面的回望。
gsub("(?<!c)h", "", strings, perl=TRUE, ignore.case = TRUE)
这篇关于去除所有“ H”。在字符串中,除了包含“ CH”的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文