-1

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?

JPGS
  • 3
  • 2

1 Answers1

0

Using package stringr instead of gsub()

stringr::str_extract_all(A, "\\w+(?='\\})")[[1]]
[1] "Comedy"  "Drama"   "Family"  "Romance"
s_baldur
  • 29,441
  • 4
  • 36
  • 69