perl如何用正则提取url中的根域名?
来源:百度知道 编辑:UC知道 时间:2024/05/26 06:52:56
#!/bin/perl -w
use strict;
my $str="http://www.5120w.com/html/program/PHP/content3504.html";
if( $str =~ m!(http:\/\/.*?\/)! )
{
print "$1\n";
}
#######################################################
#!/bin/perl -w
use strict;
my $str="http://www.5120w.com/html/program/PHP/content3504.html";
if( $str =~ s!(http:\/\/.*?\/).*!$1! )
{
print "$str\n";
}