Extract words from string in R
<p>I am trying to extract pieces of the string and creating new variables from those matched patterns. I have tried numerous of functions from the "strings" package and can't seem to get the outcome. The example below is made up data. I want to take a character string and extract the pieces and store them into new columns of a new data frame. </p>

<h2>example</h2>

<pre><code>ex &lt;- c("The Accountant (2016)Crime (vodmovies112.blogspot.com.es)","Miss Peregrine's Home for Peculiar Children (2016)FantasySci-Fi (vodmovies112.blogspot.com.es),"Fantastic Beasts And Where To Find Them (2016) TSAdventure (openload.co)","Ben-Hur (2016) HDActionAdventure (vodmovies112.blogspot.com.es)","The Remains (2016) 1080p BlurayHorror (openload.co)" ,"Suicide Squad (2016) HDAction (openload.co)")

     &gt;ex
[1] "The Accountant (2016)Crime (vodmovies112.blogspot.com.es)"
[2] "Miss Peregrine's Home for Peculiar Children (2016)FantasySci-Fi (vodmovies112.blogspot.com.es)"
[3] "Fantastic Beasts And Where To Find Them (2016) TSAdventure (openload.co)"
[4] "Ben-Hur (2016) HDActionAdventure (vodmovies112.blogspot.com.es)"
[5] "The Remains (2016) 1080p BlurayHorror (openload.co)"
[6] "Suicide Squad (2016) HDAction (openload.co)"

genres &lt;- c("Action","Adventure","Animation","Biography",
        "Comedy","Crime","Documentary","Drama","Family",
        "Fantasy","Film-Noir","History","Horror","Music",
        "Musical","Mystery","Romance","Sci-Fi","Sport","Thriller",
        "War","Western")

genres &lt;- paste0("^",genres,"|")
genres[22] &lt;- "^Western"
&gt; genres
[1] "^Action|"      "^Adventure|"   "^Animation|"   "^Biography|"
[5] "^Comedy|"      "^Crime|"       "^Documentary|" "^Drama|"
[9] "^Family|"      "^Fantasy|"     "^Film-Noir|"   "^History|"
[13] "^Horror|"      "^Music|"       "^Musical|"     "^Mystery|"
[17] "^Romance|"     "^Sci-Fi|"      "^Sport|"       "^Thriller|"
[21] "^War|"         "^Western"
</code></pre>

<h2>trying to accomplish</h2>

<pre><code>&gt; df
           title year                       domain genre
1 The Accountant 2016 vodmovies112.blogspot.com.es Crime
</code></pre>