Perl Regex to get the root domain of a URL

后端 未结 6 1913
不思量自难忘°
不思量自难忘° 2021-01-13 17:40

How could I get some part of url?

For example:

http://www.facebook.com/xxxxxxxxxxx
http://www.stackoverflow.com/yyyyyyyyyyyyyyyy

I

6条回答
  •  一向
    一向 (楼主)
    2021-01-13 18:00

    $a="http://www.stackoverflow.com/yyyyyyyyyyyyyyyy";
    if($a=~/\/\/\w+\.(.*)\// )
    {   print $1; }
    else
    { print "false";  }
    

提交回复
热议问题