title: Extract a numeric pattern between two only underscores in string
body: <p>I am relatively new to regular expressions and I am running into a dead end. I have a data frame with a column that looks like this:</p>
  
  <pre><code>year1
  GMM14_2000_NGVA
  GMM14_2001_NGVA
  GMM14_2002_NGVA
  ...
  GMM14_2014_NGVA
  </code></pre>
  
  <p>I am trying to extract the year in the middle of the string (2000,2001, etc). This is my code thus far</p>
  
  <pre><code>gsub("[^0-9]","",year1))
  </code></pre>
  
  <p>Which returns the number but it also returns the 14 that is part of the string:</p>
  
  <pre><code>142000
  142001
  </code></pre>
  
  <p>Any idea on how to exclude the 14 from the pattern or how to extract the year information more efficiently?</p>
  
  <p>Thanks</p>