
Zhris
User
Nov 4, 2010, 6:31 PM
Post #2 of 3
(2970 views)
|
This might be a practical expression:
my $url = 'http://www.abc.com/def/ghi.html'; $url =~ s/^((http\:\/\/)?[^\/]+).*$/$1/; print "$url"; Personally I would use the URI module:
use URI; my $url = 'http://www.abc.com/def/ghi.html'; my $uri = URI->new($url); my $domain = $uri->host; print "$domain"; Chris
(This post was edited by Zhris on Nov 6, 2010, 6:03 AM)
|