In the example below, how to preserve part of a pattern? The pattern search must include closing tag as spans elsewhere must not be targeted.
You need to set a capturing group and use a back reference in the replacement pattern.
regEx.Pattern = "</span>([^>]*)</h3>" hr2 = regEx.Replace(hr2,"$1</h3>")
Or
regEx.Pattern = "</span>([^>]*</h3>)" hr2 = regEx.Replace(hr2,"$1")