I would like to match just the root of a URL and not the whole URL from a text string. Given:
http://www.youtube.co
Parsing a URL can be tricky because you can have port numbers and special chars. As such, I recommend using something like parseUri to do this for you. I doubt performance is going to be a issue unless you are parsing hundreds of URLs.