title: how to use regex to extract match string in scala?
body: <p>The string is given as</p>
  <pre><code>var filedate = parser(&quot;test_pb_PP_Quality_2-Report_20200707.csv&quot;);
  </code></pre>
  <p>The Parser function to extract &quot;20200707&quot; as below.</p>
  <pre><code>def parser(filename: String):String = {
      val extractDate = &quot;&quot;&quot;(\d{8}).*&quot;&quot;&quot;.r
      val extractDate(dd) = filename;
      dd;
  }
  </code></pre>
  <p>But its return error as Exception in thread &quot;main&quot; scala.MatchError:</p>