I am strugling with regex.
I have this character vector bellow:
texts <- c('I-have-text-2-and-text-8','I-have-text-1-and-text-2','I-have-text-7-and-text-8','I-have-text-2-and-text-1','I-have-text-4-and-text-5','I-have-text-11-and-text-12','I-have-text-13-and-text-32','I-have-text-8-and-text-6')
I have two words important to me: text-1
and text-2
. And I need them both, in any order.
I want to extract the text with them.
The output should be: [1]'I-have-text-1-and-text-2' [2]I-have-text-2-and-text-1
Ive been using str_subset from stringr
but I dont know the regex expression for this.
str_subset(texts, 'regex')
Any help