If you use emacs and don't already understand how to use
regexp based search and replace, you should look into how to
do it. My god it makes life easier!
Another nice function to use when you are developing your emacs regexps is isearch-forward-regexp. If you have color, emacs will highlight the matches as you type your regexp! I've finally overcome my regexphobia and actually look forward to opportunities to use them.