3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str=" <b>test</b> <pre> <b>test</b> </pre> <b>test</b> "; echo preg_replace_callback(htmlspecialchars('~(?s)<pre>.*?</pre>~'), function($match) { return htmlspecialchars_decode($match[0]);}, preg_replace('~<(/?)b>~','[$1b]', preg_replace_callback('~(?s)<pre>.*?</pre>~', function($match) { return htmlspecialchars($match[0]);}, $str)));

preferences:
31.74 ms | 407 KiB | 5 Q