Interactive Regexp and Replacing Regexp with Emacs
If we need to replace text based on patterns, then replace-regexp is the command.
But we may not always be sure that the regular expression (RE) entered does what we wanted. Not to worry, emacs has it covered: with re-builder! As we keep entering the text, the editor progressively highlights the text in the buffer that matches. Once we are certain that all the required text has matched, we can move to enter the command to replace it.
We'll look at a usecase where we need to uppercase some sql keywords, and cast the output of a function as float
In replace-regexp, the matched expressions are grouped using \( ... \), and the matched groups can be accessed in the result as \1, \2, etc.