I want to extract the genres in this character using gsub A<-("[{'id': 35, 'name': 'Comedy'}, {'id': 18, 'name': 'Drama'}, {'id': 10751, 'name': 'Family'}, {'id': 10749, 'name': 'Romance'}]")
.
How may I do this?
Using package stringr
instead of gsub()
stringr::str_extract_all(A, "\\w+(?='\\})")[[1]]
[1] "Comedy" "Drama" "Family" "Romance"