I want to extract the two words preceding a Twitter @handle
x <- c("this is a @handle", "My name is @handle", "this string has @more than one @handle")
Doing the following extracts all the text preceding the last @handle only, I need it for all @handles
(ext <- stringr::str_extract_all(x, "^.*@"))
[[1]]
[1] "this is a @"
[[2]]
[1] "My name is @"
[[3]]
[1] "this string has @more than one @"