3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "/companies/(\d+)/adverts/new/(\d+)"; preg_match_all('#\((.*?)\)#', $string, $matches); $search = $matches[0]; $replace = array(2223, 'generic'); $result = strtr($string, array_combine($search, $replace)); var_dump($result);

preferences:
39.16 ms | 402 KiB | 5 Q