Skip to content

Instantly share code, notes, and snippets.

@auramo
Last active December 27, 2015 17:09
Show Gist options
  • Save auramo/7359846 to your computer and use it in GitHub Desktop.
Save auramo/7359846 to your computer and use it in GitHub Desktop.
MONGOHQ_URL regex (Scala) which works with username containing dashes
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