fork download
  1. go <- c("go after it", "here we go", "he went bust", "go get it go", "i 'm gon na go", "she 's going berserk")
  2. lemma_GO <- c("go", "goes", "going", "gone", "went", "gon na")
  3. pattern_GO <- paste0("\\b(", paste0(lemma_GO, collapse = "|"), ")\\b")
  4. library(stringr)
  5. str_extract_all(go, paste0("('?\\b[a-z']+\\b|^)(?=\\s?", pattern_GO, ")"))
  6.  
Success #stdin #stdout 0.32s 41820KB
stdin
Standard input is empty
stdout
[[1]]
[1] ""

[[2]]
[1] "we"

[[3]]
[1] "he"

[[4]]
[1] ""   "it"

[[5]]
[1] "'m" "na"

[[6]]
[1] "'s"