3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $domains[] = 'www.wp.pl'; $domains[] = 'http://www.onet.pl/plp/costam'; $domains[] = 'onet.pl'; $domains[] = 'https://redtube.com/porn'; $domains[] = 'http://wwww.gżegżółka.www..w3schooåøls.coøm/pl/polska/index.php?id=op&pids=1'; $domains[] = 'http://wwww.gżegżółka.www.<script>alert(\'test\');</script>.w3schooåøls.coøm/pl/polska/index.php?id=op&pids=1'; print_r(array_map(function ($domain) { preg_match('#(https?:\/\/)?(www\.)?([a-z][^\/]+)#', $domain, $matches); return $matches[3]; }, $domains));
based on 7CTbk
Output for 5.6.0 - 5.6.30, hhvm-3.18.5 - 3.22.0, 7.0.0 - 7.2.8
Array ( [0] => wp.pl [1] => onet.pl [2] => onet.pl [3] => redtube.com [4] => wwww.gżegżółka.www..w3schooåøls.coøm [5] => wwww.gżegżółka.www.<script>alert('test');< )