我想提取 Twitter @handle 前面的两个词
x <- c("this is a @handle", "My name is @handle", "this string has @more than one @handle")
执行以下操作仅提取最后一个@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 @"