Try using re.sub with a callback function:
def replace_div(m):
return re.sub(r'\bclass="col-xs-12"', 'class="column-md"', m.group(0))
inp = 'blah <b>stuff</b> blah <div class="col-xs-12">100/25</div> more blah'
out = re.sub(r'<div[^>]*\bclass="col-xs-12"[^>]*>.*?</div>', replace_div, inp)
print(inp)
print(out)
This prints:
blah <b>stuff</b> blah <div class="col-xs-12">100/25</div> more blah
blah <b>stuff</b> blah <div class="column-md">100/25</div> more blah
The strategy here is to first match all <div> tags containing the appropriate class attribute. Then, we pass such matches to a callback function which then does the class replacement.
Note that in general using regex on nested content like HTML is not recommended. But, sometimes we are forced to manipulate such content using a text editor.