domain regex split

前端 未结 4 1214
情深已故
情深已故 2021-01-27 08:20

I have some domains I want to split but can\'t figure out the regex...

I have:

  • http://www.google.com/tomato
  • http://int.google.c
4条回答
  •  甜味超标
    2021-01-27 08:49

    $res = preg_replace( "/^(http:\/\/)([a-z_\-]+\.)*([a-z_\-]+)\.(com|co.uk|net)\/.*$/im", "\$3", $in );
    

    Add as much endings as you know

    Edit: made a mistake :-(

提交回复
热议问题