The documentation available is terse on how to use the replace-regexp function. Lately I have needed to do a rather large number of complex replacement’s across code. Here are some things that I should definitely remember next time:
M-x replace-regexp RET \(.*\)-safe RET \1 RET
- Parenthesis used for matching values for replace always need to be escaped in emacs. There are no exceptions and you will go insane if you do not remember this.
‘ in newstring stands for the entire text being replaced. You don’t need to match the entire string to add to it.