Let s see a few examples. The replacement text b 1 b replaces each regex match with the text stored by the capturing group between bold tags. I thought the regex below would work but it is replacing everything including.