Can I find and replace a message I write in Gmail? The web pages are for reading purposes and therefore the developers did not make sure to include the "find and replace" feature in the browser code.
Websites, however, have evolved and now have not only static content. So if you write long emails or even want to find text in webpages, and you want to fix annoying misspellings, you need to fix them one by one.
You can not automatically replace a word or phrase on a webpage without using browser extensions.
The following publication will show you a simple technique to help you search for and replace text on web pages using the built-in Chrome Developer Tool.
Open a page you want to edit.
While on the web page, press the three Ctrl + Shift + J keys on a Windows or Cmd + Opt + J on Mac system to open the Chrome Developer Tools console window.
Immediately after, give the following command to replace all appearances of the word iguru with iguru.gr.
document.body.innerHTML = document.body.innerHTML.replace (/ iguru / g, "iguru.gr")
You can use regular expressions for more complex substitutions. For example, if you want to replace all common misspellings, you could use some of these:
document.body.innerHTML.replace (/ (iguru | igurunews) / g, "iGuRu News") document.body.innerHTML.replace (/ ig [\ w] + ews / g, "iGuRu News")
The same technique can be used to format a page. For example, the next command will bold the word iguru on a page.
document.body.innerHTML.replace (/ iguru / g, "<iguru")
Search and replace text in Gmail
Of course, your changes are not saved on the page you are editing when you close the browser tab.
Can you wonder why someone will search and replace on a website?
To explain the practicality of the above tweak, we'll give an example with Gmail.
You may have written a big email, but you find out before it is written that it contains misspellings.
To fix bugs in Gmail in bulk, you can copy the e-mail to a notebook, and search and replace. Then paste the processed text back into Gmail. Or you can directly use Chrome Dev tools.
In our previous example, we searched and replaced in document.body, which is addressed to websites. Let's see how it works in Gmail.
The first step is to find the word in the message you want to search & replace. Select the text you want in the Gmail window, right-click and select Item Review. It will give you the identity of the DIV that contains the editable text area. In our case it is ": 1cv" for Gmail.
Now all you need to do is run the following replacement command in the console window to replace the word iguru with the word igurunews everywhere.
document.getElementById (': 1cv'). innerHTML = document.getElementById (': 1cv') innerHTML.replace (/ iguru / g, "igurunews");