Extract text between double quotes in R
I have a cell with the text ["bestsellers", "mysteries_thrillers_true_crime", "science_fiction_fantasy", "literary_fiction"]
Desired result - all types in a cell:
[1]"bestsellers"
[2]"mysteries_thrillers_true_crime"
[3]"science_fiction_fantasy"
[4]"literary_fiction"
To extract the text between double quotes, I tried
str_extract(data$preferences[1], "\\[\".*?\"\\]")
and
str_extract(data$preferences[1], "\".*?\"")
both got the result:
[1] "[\"bestsellers\",\"mysteries_thrillers_true_crime\",\"science_fiction_fantasy\",\"literary_fiction\"]
My question is: how to get rid of [and] and get the result of desire?
+3
source to share
No one has answered this question yet
See similar questions:
or similar: