Text Functions in Notion formulas! (Part Two)

Formulas in databases hold the key to the hidden potential of Notion! From complex mathematical calculations to automating certain actions, you can do so much if you know how to build custom formulas! In this article, I will explain some text functions in Notion formulas along with some simple examples.

In the previous article of the Fantastic Formulas, we learned how to use the first 4 Text-functions in Notion formulas. Make sure to check out the previous articles in this series for a compete guide to Notion formulas!

There are 5 remaining Text functions:

  1. length
  2. replace
  3. replaceAll
  4. slice
  5. test

Let us create a simple database to track/manage daily Tweets in Notion. As you can see below:

Simple Tweet Tracker

The 'Name' property shows the serial number of the tweet and the 'Tweet Content' property shows the content of the Tweet.

1. length()

The length function returns the number of characters in a text string. The function takes a single argument, which is the text string to measure. The function returns an integer representing the number of characters in the string.

For example:

length(prop("Tweet Content"))
length() function example

As you can see below, this formula shows the total number of characters used in the tweet! 🔽

length() example results

2. replace()

The replace function allows you to replace a specified substring within a text string with another string. The function takes three arguments: the text string to modify, the substring to replace, and the string to replace it with. The function returns a new text string with the specified substring replaced.

For example:

replace(prop("Tweet Content"), ":fire:", "🔥")
replace() function example

As you can see below, this formula replaces ":fire:" with the fire-emoji! 🔽

replace() example results

3. replaceAll

The replaceAll function allows you to replace all occurrences of a specified substring within a text string with another string. The function takes three arguments: the text string to modify, the substring to replace, and the string to replace it with. The function returns a new text string with all occurrences of the specified substring replaced.

For example:

replaceAll(replaceAll(replaceAll(prop("Tweet Content"),
 ":fire:", "🔥"), ":hundred:", "💯"), ":wink:", "😉")
replaceAll() function example

As you can see below, this formula uses the replaceAll function to replace all the keywords with their respective emojis! 🔽

replaceAll() example results

4. slice()

The slice function allows you to extract a portion of a text string. The function takes three arguments: the text string to extract from, the start index, and the end index. The start index and end index specify the portion of the string to extract, and are zero-based. The function returns the specified portion of the string.

For example:

slice(prop("Name"), 6)
slice() function example

As you can see below, this formula displays the content of 'Name' property but only the content after the 6th character! 🔽

slice() example results

5. test()

The test function allows you to match a text string against a regular expression. The function takes two arguments: the text string to match and the regular expression to match against. The function returns a Boolean value indicating whether the text string matches the regular expression.

For example:

test(prop("Tweet Content"), "Time")
test() function example

As you can see below, this formula uses the test() function to check wether the 'Tweet Content' property contains the specified keyword or not! 🔽

test() example results

Conclusion

So now you know how to use Text functions in Notion formulas! You can use these functions to build custom formulas in your personal Notion space. Using formulas can help you get the most out of Notion. You can also use our shortcut commands template to be more efficient using these.

Make sure to check out the Fantastic Formulas series for a complete guide on Notion formulas! Follow us on Twitter for daily motivation, new template launches and super-saver deals on Top-rated Premium Notion templates! And if you know some tips/tricks that you want to share with other Notion users, you can write for us! Reach us via hello@prototion.com