【发布时间】:2013-08-12 10:58:07
【问题描述】:
如何在 R 中使用正则表达式从文本字符串中提取 Twitter 用户名?
我试过了
library(stringr)
theString <- '@foobar Foobar! and @foo (@bar) but not foo@bar.com'
str_extract_all(string=theString,pattern='(?:^|(?:[^-a-zA-Z0-9_]))@([A-Za-z]+[A-Za-z0-9_]+)')
但我最终得到@foobar、@foo 和(@bar,其中包含不需要的括号。
我怎样才能只得到@foobar、@foo 和@bar 作为输出?
【问题讨论】: