3v4l.org

run code in 500+ PHP versions simultaneously
<?php $replacer = 'href="https://example.net"'; $homepage = preg_replace_callback('/<body.*?>(.*)<\/body>/', function($matches) use($replacer) { return preg_replace("/(?<=href=(\"|'))[^\"']+(?=(\"|'))/",$replacer,$matches[0]); },'<body><a class="attribute" href="https://mother.com"/> <a class="attribute" href="https://mothers.com"></a></body>'); echo $homepage;

preferences:
102.05 ms | 1285 KiB | 5 Q