I can be given a string in any of these formats:
url: e.g http://www.acme.com:456
string: e.g www.acme.com:456, www.acme.com 456, or www.acme.co
The reason it fails for:
www.acme.com 456
is because it is not a valid URI. Why don't you just:
:
urlparse
methodTry and make use of default functionality as much as possible, especially when it comes to things like parsing well know formats like URI's.