0; $index--) { $pr = '/(^#{' . $index . '} .{1,})/m'; preg_match_all($pr, $string, $headers); if (isset($headers[0][0])) { foreach ($headers[0] as $header) { $hI = $index+1; $string = str_replace($header, "" . mb_substr($header, $index + 1, NULL, 'UTF-8') . "", $string); } } } return $string; } static private function replaceBold($string) { $pr = '(\*{2}(.+?)\*{2})'; $rep = '$1'; return preg_replace($pr, $rep, $string); } static private function replaceItalic($string) { $pr = '(\*{1}(.+?)\*{1})'; $rep = '$1'; return preg_replace($pr, $rep, $string); } static private function replaceUnderline($string) { $pr = '(\_{1}(.+?)\_{1})'; $rep = '$1'; return preg_replace($pr, $rep, $string); } static private function replaceUrls($string) { $pr = '((https{0,1}:\/\/[\da-z\.-]+\.[a-z]{2,6})[\/\w\?=&#%+\.,-]*\/?)'; $rep = '$1'; return preg_replace($pr, $rep, $string); } }