To replace a string in the Emacs text editor, press ALT+SHIFT+5 (ALT+%) to first find the occurrence of the string. Emacs will prompt you to enter the string to find and replace. Once there’s a match, it will be highlighted. Now, press ENTER and type the word that will replace the found query. Again, press ENTER and press Y to replace the string in Emacs or press “!” (exclamation mark) to replace all the available matches without asking. Additionally, press N to skip replacing the current occurrence and CTRL+G to cancel the entire replacement process in Emacs. Moreover, you can replace using regular expressions by pressing CTRL+ALT+SHIFT+5.