title: Extracting date from string in R using regex
body: <p>I have the following data frame:</p>
  
  <pre><code>    V1 &lt;- c("path/to/file/filename-Aug-4-2017-_to-Aug-4-2017_otherinfo_.csv", "otherpath/to/file/filename-Aug-18-2017-_to-Aug-18-2017_otherinfo_.csv")
      df &lt;- as.data.frame(V1)
  </code></pre>
  
  <p>And I would like to be able to extract the date (formatted as a date) into a new column called df$Date. I've done something similar before using a combination of regex and <code>str_extract</code> like so:</p>
  
  <pre><code>    df$Date &lt;- str_extract(df$V1, "\\d{4}-\\d{2}-\\d{2}")
  </code></pre>
  
  <p>But I'm not sure how I would do this with the dates in this format and really don't understand Regex enough to figure it out. Any help would be greatly appreciated. </p>
  
  <p>Also open to alternative methods or approaches. Thanks!  </p>