【发布时间】:2016-10-16 02:38:45
【问题描述】:
我想提取 Twitter @handle 前面的两个词
x <- c("this is a @handle", "My name is @handle", "this string has @more than one @handle")
执行以下操作仅提取 last @handle 之前的所有文本,所有@handle 我都需要它
(ext <- stringr::str_extract_all(x, "^.*@"))
[[1]]
[1] "this is a @"
[[2]]
[1] "My name is @"
[[3]]
[1] "this string has @more than one @"
【问题讨论】:
-
你可能想要
str_split