title: How to extract date from String column using regex in Spark
body: <p>I have a dataframe which consist of filename, email and other details. Need to get the dates out of it from one of the column file name. </p>
  
  <p>Ex: <strong>File name</strong>: Test_<strong>04_21_2019</strong>_34600.csv</p>
  
  <p><strong>Need to extract the date</strong>: 04_21_2019</p>
  
  <p><strong>Dataframe</strong></p>
  
  <pre><code>val df1 = Seq(
    ("Test_04_21_2018_1200.csv", "abc@gmail.com",200),
    ("home/server2_04_15_2020_34610.csv", "abc1@gmail.com", 300),
    ("/server1/Test3_01_2_2019_54680.csv", "abc2@gmail.com",800))
  .toDF("file_name", "email", "points")
  </code></pre>
  
  <p><strong>Output To be</strong></p>
  
  <pre><code>date         email           points
  04_21_2018   abc@gmail.com   200
  04_15_2020   abc1@gmail.com  300
  01_2_2019    abc2@gmail.com  800
  </code></pre>
  
  <p>Can we use regex on spark dataframe to achieve this or any other way to achieve this. Any help will be appreciated.</p>