<?php function replace_text($text) { return preg_replace(array('/(?<!\\\\)`((?:[^`\\\\]|\\\\.)*)`/', '/\\\\`/'), array('<code>$1</code>', '`'), $text); } $text = 'some words \` and `some code` and `some \`more code` again'; echo replace_text($text);
You have javascript disabled. You will not be able to edit any code.