pattern = string.Format(@" (?: (?<=nn) # Starting after a blank line | # or An? # the beginning of the doc ) ( # save in $1 [ ]{{0, {0}}} <(hr) # start tag = $2 b # word break ([^<>])*? # /?> # the matching end tag [ t]* (?=n{{2,}}|Z) # followed by a blank line or end of document )", tabWidth - 1); text = Regex.Replace(text, pattern, new MatchEvaluator(HtmlEvaluator), RegexOptions.IgnorePatternWhitespace);