\\1', '\\1', '\\1', '

\\1

', '

\\1

', '\\2', '\\2', '', '
    \\1
', '
  • \\1
  • ', '', '', '' ); // perform the replacement $step_1 = preg_replace($search, $replace, $str); $step_2 = preg_split('#(\{HTML\}.*?\{/HTML\})#is', $step_1, -1, PREG_SPLIT_DELIM_CAPTURE); $return = ''; foreach ($step_2 as $s2) { if (preg_match('#\{HTML\}#', $s2)) { $return .= preg_replace('#\{/?HTML\}#is', '', $s2); } else { $return .= nl2br($s2); } } // return HTML markup return $return; } ?>