Not to discourage you, but I don't think it is as simple as one would think. Consider http://domain.co.uk - no subdomain, but you'd probably wouldn't want to end up with co.uk, as would be likely to happen with a simple pattern. or imagine users entering a numeric IP instead...
Now here's a simple one for use with preg_replace, but mind the above
§^[url]http://[/url][^.]+\.§
it uses § as delimiter to keep you from escaping the slashes in [url]http://[/url] and will grab the first sequence of anything that is not a dot, followed by a dot (make sure you escape this one with a backslash).
[edited typo]