3v4l.org

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