Let's say I have a db url string which looks like this:
"mysql2://foo:bar@baz.com/fizz?reconnect=true"
and I came up with a regex for extracting a username, password and host name:
/\w:\/\/(\w+):/ # extracts username ("foo")
/\w:\/\/\w+:(\w+)/ # extracts password ("bar")
/\w:\/\/\w+:\w+@([\w+-\/]+)/ # extracts host name ("baz.com")
How can this regex be improved / made more efficient?