Off the top of my head, you could probably do something like this:
[EDIT: Please don't do it off the top of my head; a desk would be much more comfortable for both of us.]
[PHP]
if(preg_match('/([-\w_]+(?:\.\w{2,4})+)(?=(\/|$))/', $_REQUEST['domain'], $matches)) {
var_dump($matches);
...
[/PHP]
This will match any alphanumeric or hyphen/underscore characters, then any series of subdomains (alphanumeric only, 2-4 chars), immediately preceding either the first '/' character, or the end of the string.
This matches stuff like 'yahoo.co.uk', 'army.mil', 'google.com', but admittedly it also matches '------------------------------------.mug', so you might have to do a little extra validation.
[EDIT: Incidentally, $matches has three elements after running this regex on my system, but it should only have one. Apparently, the PCRE engine in PHP 5.2.1 (or at least the one I compiled on my Mac) does not properly support non-capturing parenthesis nor lookaheads properly.]