title: Pivot_longer in R with names_pattern
body: <p>I have very limited experience with regular expressions and I'm having trouble using them with names_pattern. </p>
  
  <p>My data frame is in wide format with the columns titled 
  X1998..YR1998.    X1997..YR1997.     X1996..YR1996.
  etc. </p>
  
  <p>I want to pivot to a long format with row for years being 1998, 1997, 1996, etc. This is what I tried. </p>
  
  <pre class="lang-r prettyprint-override"><code>df.gdp.long &lt;- pivot_longer(df.gdp, cols=starts_with("X"), names_to=c('year',"year"),
                              names_prefix="X", names_pattern = 'X(.)..YR(.).',
                              values_to="gdp")
  </code></pre>
  
  <p>However, right now the rows say X1998..YR1998. etc. Do you have a suggestion using names pattern? Or anything else? </p>
  
  <p>Thanks in advance!  </p>