Why does the following python regex not generate @Summary\n?
import re
re.sub('$~ ','@','~ Summary\n')
The anchor $ means "the position at the end of the string".
You need to use a different anchor for "the position at the start of the string":
re.sub(r'^~ ','@','~ Summary\n')
^?re.sub(r'\$~ ','@','$~ Summary\n') instead! (in order to get the expected result)