You can just use str_replace:
$str = str_replace(array('<pre>', '</pre>'), array('<code>', '</code>'), $str);
If you are forced to use regexp:
$str = preg_replace("~<(/)?pre>~", "<\\1code>", $str);
If you want to replace them separately:
$str = preg_replace("~<pre>~", '<code>', $str);
$str = preg_replace("~</pre>~", '</code>', $str);
You just need to avoid this slash.
source
share