preg replace

preg_replace

Replaces the matches in the subject with the specified replacement.

$text = 'The definition of [recursion] may not be [obvious].';
echo preg_replace(/[([^]]+)]/, <b>1</b>, $text);
$text = 'The definition of <h1>recursion</h1> may not be <h1>obvious</h1>.';
echo preg_replace(@<h1[^>]*?>.*?</h1>@siu, '', $text);
$str ='asdfd adsfd aaaadasd'; 
echo $str = preg_replace(/(a)(.*)?(d)/U,a($2)d,$str);