Skip to content

Instantly share code, notes, and snippets.

@hsanchez
Forked from auramo/gist:7359846
Created June 10, 2014 23:22
Show Gist options
  • Save hsanchez/58b42924db43930d879b to your computer and use it in GitHub Desktop.
Save hsanchez/58b42924db43930d879b to your computer and use it in GitHub Desktop.
val regex = """mongodb://(\w+):([\w|-]+)@([\w|\.]+):(\d+)/(\w+)""".r
url match {
case Some(regex(u, p, host, port, dbName)) =>
ConnectionParams(host, port.toInt, dbName, u, p)
case None => {
ConnectionParams("127.0.0.1", 27017, "mylocaldb")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment