Reputation: 6018
Why does the following python regex not generate @Summary\n
?
import re
re.sub('$~ ','@','~ Summary\n')
Upvotes: 2
Views: 308
Reputation: 336108
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')
Upvotes: 3