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, "//$hostName$3/", $url ));
Output for 4.3.0 - 7.2.0
array(5) { [0]=> string(26) "https://roger.shopery.dev/" [1]=> string(1) "s" [2]=> string(17) "roger.shopery.dev" [3]=> string(0) "" [4]=> string(0) "" } string(17) "//gros.cat/admin/"