3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $url = 'https://roger.shopery.dev/admin/'; $hostName = 'gros.cat'; $pattern = '~(http)(s?)://([a-zA-Z0\.-9]+)([:0-9]+)?/(.*)~U'; preg_match($pattern, $url, $matches); var_dump( $matches ); var_dump( preg_replace( $pattern, "$1://$hostName$4/", $url ));
Output for 4.3.0 - 7.2.0
array(6) { [0]=> string(26) "https://roger.shopery.dev/" [1]=> string(4) "http" [2]=> string(1) "s" [3]=> string(17) "roger.shopery.dev" [4]=> string(0) "" [5]=> string(0) "" } string(22) "http://gros.cat/admin/"