Regex to match any character repeated three or more times in R

时光总嘲笑我的痴心妄想 提交于 2021-01-29 02:28:58

问题


What is the Regex to match any character repeated three or more times in R (e.g. "aaargh", "arrrrrgh", "yesssssss")? I read the solution for Python, PHP and PCRE on Stack Overflow, but they don't seem to be applicable to R. Thanks.


回答1:


We can use grep

 grep("(.)\\1{2,}", v1)

data

 v1 <- c("aaargh", "arrrrrgh", "yesssssss")


来源:https://stackoverflow.com/questions/38263441/regex-to-match-any-character-repeated-three-or-more-times-in-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!