tan*_*nay 4 regex string r gsub
我想删除那些单词中字母数/特殊字符数同时出现两次以上的单词.
对于Eg,输入就像
"Google in theee lland of whhhat c#, c++ and e###"
Run Code Online (Sandbox Code Playgroud)
输出应该是
"Google in lland of c#, c++ and"
Run Code Online (Sandbox Code Playgroud)
x <- "Google in theee lland of whhhat c#, c++ and e###"
gsub("\\S*(\\S)\\1\\1\\S*\\s?", "", x)
# [1] "Google in lland of c#, c++ and "
Run Code Online (Sandbox Code Playgroud)
(\\S)\\1\\1 找到单个非空格字符的三个连续重复的序列.
周围\\S*并且\\S*\\s?只捕获同一个单词中的前后字符,以及紧跟该单词后面的任何单个空格.