- Introduction
- Does Notion natively support find and replace?
- Using external tools
- Using Notion database
- Find and replace Chrome extension
- Pattern matching with Regular expressions
- Regular expressions reference
- Bonus
Introduction
Imagine this scenario: You are making a report on recent changes since the last software update and only hours later you realize you’ve used the wrong version number. What a painstaking experience that would be without find and replace each and every entry. You’ll have to manually search through for the wrong version number and replace it with the correct version, one by one in the entire text. Wouldn’t it be nice if you could just find all and replace them in one go.
Does Notion natively support find and replace?
Unfortunately, No.
At the time of writing this post in Jan-2023, Notion doesn’t natively support find and replace.
Though it has been on Notion’s radar since May 2019 and there has been no update.
Yerba on Twitter is even willing to sell their wife and kids for this to be added.
Using external tools
This is the most straightforward approach, you just need to copy over the text that you wish to change and paste it in the text editor of your choice. Run the find and replace command. Take the resulting text back to Notion. You can use the following tools
Classic text processors
- Word: The most iconic word processor of all time released by Microsoft about 40 years ago.
- Docs: An online document editing and collaboration tool from Google. You don’t have to pay to use this, just need a google account.
- Code Editors: You can also use VSCode, Sublime Text, Vim, Emacs, or any other text editor of your choice as they come with this feature right of the box as well.
Simple Online Tools
- onlinetexttools.com: This is a collection of pretty handy text manipulation tools, you don’t even need to sign up just past your text, and done.
- joydeepdeb.com’s tool: This is more advanced as it allows you to change multiple items at once. Like in the above example both the two items (Bob→Alice, builder→Carpenter) have been changed in one go.
Using Notion database
It’s true that Notion doesn’t provide find and replace for in-page content but that isn’t necessarily true for databases. Using the Notion formula replaceAll()
we can achieve the same results as any other text processor with find and replace functionality.
As in the above image create a simple database with three two fields, input
that store the text we want to process over and the respective find
and replace
text. Now create a formula property called Result
that will give us the required output. You can copy the formula from here.
replaceAll(prop("Input"), prop("Find"), prop("Replace"))
Here the replaceAll()
formula takes the Input
text and finds the find
text and for each occurrence found it replaces it with Replace
text and the resulting output is shown as Result
.
Name | Input | Find | Replace | Result |
---|---|---|---|---|
Text Sample | Bob the builder, always working hard
Bought the tools needed to do the job
Bought a hammer, saw, and a drill
Bob was ready to build with skill
Bob worked hard and never shied
Building things with his tools beside
Bob the builder, always working away
Building structures that were here to stay
Bob was precise and very neat
The job was done, a perfect treat
Bob the builder, a master of the craft
Making sure the job was done right | Bob | Alice | Alice the builder, always working hard
Bought the tools needed to do the job
Bought a hammer, saw, and a drill
Alice was ready to build with skill
Alice worked hard and never shied
Building things with his tools beside
Alice the builder, always working away
Building structures that were here to stay
Alice was precise and very neat
The job was done, a perfect treat
Alice the builder, a master of the craft
Making sure the job was done right |
Find and replace Chrome extension
This hack was found by u/chi11estpanda on r/Notion, in this method you go through each occurrence and then replace the text after two additional clicks. It’s not perfect, not even a complete solution but hey far better than manually searching and replacing it all manually.
So, how does it work? Firstly you have to get this Find and Replace Chrome extension.
Head over to the page you want to do the changes.
- Open the extension, enter the search term and replacement term, and set the option for "In-text selection"
- Manually find the first occurrence of the word by using default browser search function (Ctrl+F),
- Then manually double-click the word to highlight in Notion
- Use hotkey Ctrl+Shift+F to bring up the extension, and hit replace
- Go back to the default browser search function to have it take you to the next occurrence of the word
- Manually highlight, use hotkey, click replace, rinse, wash, repeat ~ u/chi11estpanda
Pattern matching with Regular expressions
Regular expressions are powerful tools for finding patterns in text.
They are composed of symbols, characters, and anchors which represent text that can be searched for.
By using character classes, brackets, and quantification, one can create powerful expressions to search for patterns.
For example, /[A-Z]+/g
will match all strings of capital letters in a document.
You can make use of regex101.com and regexr.com to create, test and learn more about regular expressions. Once you have the search pattern ready, you can make use of any find-and-replace tool that works with regular expressions. Notepad++ provides this functionality too. You can also use any online tool like pinetools.com/find-and-replace.
Regular expressions reference
- Basics
/ expression / flags
, i.e/[A-Z]+/g
basic format/ hello\\?\\*\\\\/
escape special characters with backslashes()
group with parentheses|
logical OR- Character classes
\w
word ||\W
NOT word\d
digit ||\D
NOT digit\s
whitespace (tabs, line breaks) ||\S
NOT whitespace\\t
tabs,\\n
line breaks.
any character (except newline)- Brackets
[xyz]
match any x, y, z[J-Z]
match any capital letters between J & Z.[^xyz]
NOT x, y, z- Quantification
bob|alice
match bob or alicez?
zero or one occurrencesz*
zero or multiple occurrencesz+
one or multiple occurrencesz{n}
n occurrencesz{min,max}
min/max occurrences- Anchors
hello world
exact match^hello
start of the stringsworld$
end of the string- Modes
greedy
matches longest possible partlazy
matches smallest possible part
Bonus
While researching, I also came across “Search and Replace with Notion API SDK Javascript”. The post is by Andrei who succeeded in getting it to work with text blocks and paragraphs. This method requires an understanding of Node.js and javascript as prerequisites. Feel free to use these resources if you need to.