title: String pattern matching best practice
body: <p>Following is the code that doesn't work but it describes what I want to do.</p>
  
  <p>Could you please recommend the best approach to this problem?</p>
  
  <pre><code>def resolveDriver(url: String) = {
    url match {
      case url.startsWith("jdbc:mysql:") =&gt; "com.mysql.jdbc.Driver"
      case url.startsWith("jdbc:postgresql:") =&gt; "org.postgresql.Driver"
      case url.startsWith("jdbc:h2:") =&gt; "org.h2.Driver"
      case url.startsWith("jdbc:hsqldb:") =&gt; "org.hsqldb.jdbcDriver"
      case _ =&gt; throw new IllegalArgumentException
    }
  }
  </code></pre>