^(http://[^/]*) #### my $foo = "http://www.hostname.co.uk/foo/bar"; print $foo =~ m#^(http://[^/]*)#;