title: create new variable based on a regular expression
body: <p>My question involves how to create a new variable on a data frame in R based on the result of a regular expression. 
  Below is a minimal example of the data:</p>
  
  <pre><code>df &lt;- data.frame(model=c("Legacy 2.0  BG5 B4 AUTO","Legacy 2.0 BH5 AT","Legacy 2.0i CVT Non Leather","Legacy 2.0i CVT","Legacy 2.0 BL5 AUTO B4",
                   "Legacy 2.0 BP5 AUTO","Legacy 2.0 BM5 AUTO CVT"), CRSP=c(3450000,3365000,4950000,5250000,4787526,3550000,5235000))
  
  df
                          model    CRSP
  1     Legacy 2.0  BG5 B4 AUTO 3450000
  2           Legacy 2.0 BH5 AT 3365000
  3 Legacy 2.0i CVT Non Leather 4950000
  4             Legacy 2.0i CVT 5250000
  5      Legacy 2.0 BL5 AUTO B4 4787526
  6         Legacy 2.0 BP5 AUTO 3550000
  7     Legacy 2.0 BM5 AUTO CVT 5235000
  </code></pre>
  
  <p>I would like to create a new variable 'chassis' whose value is the third element of the corresponding 'model' variable string, thus ending up with:</p>
  
  <pre><code>df
                          model    CRSP chassis
  1     Legacy 2.0  BG5 B4 AUTO 3450000     BG5
  2           Legacy 2.0 BH5 AT 3365000     BH5
  3 Legacy 2.0i CVT Non Leather 4950000     CVT
  4             Legacy 2.0i CVT 5250000     CVT
  5      Legacy 2.0 BL5 AUTO B4 4787526     BL5
  6         Legacy 2.0 BP5 AUTO 3550000     BP5
  7     Legacy 2.0 BM5 AUTO CVT 5235000     BM5
  </code></pre>
  
  <p>I need to find a way of extracting the appropriate elements in each row and place them in the new variable. 
  Any assistance would be greatly appreciated. </p>