且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用 R 在文本中使用相同模式提取字符串

更新时间:2023-11-07 17:50:34

我们可以做到

str_extract_all(text, "(?<=#)\\w*(?=#)")[[1]]
#[1] "Pray4Manchester" "ArianaGrande"   

数据

text <- "#Pray4Manchester# I hope that #ArianaGrande# will be better soon."