Perl Regex to get the root domain of a URL

后端 未结 6 1955
不思量自难忘°
不思量自难忘° 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:18

    This Might be helpful...

    ^https?:\/\/www\.([\da-zA-Z\.-]+)

    Sample Input:

    http://www.banglanews24.com/detailsnews.php
    nssl=763daee77dc90b1c1baf0a361be2ff3c&nttl=20130416072403189462
    
    http://www.prothom-alo.com/detail/date/2013-04-20/news/3463
    
    http://www.facebook.com/xxxxxxxxxxx
    
    http://www.stackoverflow.com/yyyyyyyyyyyyyyy
    

    Sample output:

    banglanews24.com
    
    prothom-alo.com
    
    facebook.com
    
    stackoverflow.com
    

提交回复
热议问题