4
I’m having trouble using the str_detect
to capture part of a text.
I need the str_detect
take only the word "garlic", but regardless of her position in the string. Ex: "Brazilian garlic", "Brazilian garlic producers" or "garlic manufacturers".
Example:
str_detect(c("produção e trabalho","fabricante de alho",
"alho brasileiro","produtores de alho brasileiro"),
paste(c("carro", "futebol",
"^|[[:space:]]alho[[:space:]]|$"),collapse = '|'))
In this example, the str_detect
is taking the words "work" and "garlic".
--
It is possible to solve with regex or another function?
I will use this logic for many words in a vector.
Excellent! With
\\b
was show!– RxT