如何从字符串中提取 group/list 个单词中包含的单词?

How do I extract a word, that is contained in a group/list of words, from a string?

来自字符串的字符向量

x <- c("Point to Point Movement, Route/Network Building",                                                                       
       "Betting/Wagering, Dice Rolling, Roll / Spin and Move",
       "Hand Management, Take That")

提取包含在

中的单词
p <- c("Route","Dice")

否则NA。生成的输出将是来自 x[1] 的“Route”、来自 x[2] 的“Dice”和来自 x[3].

NA

将单词粘贴为单个字符串并在 str_extract

中使用
library(stringr)
str_extract(x, str_c(p, collapse="|"))
[1] "Route" "Dice"  NA