<aside> <img src="https://s3-us-west-2.amazonaws.com/secure.notion-static.com/5f290176-d74d-4847-824b-f173f3489a87/tfexplains-profile.jpg" alt="https://s3-us-west-2.amazonaws.com/secure.notion-static.com/5f290176-d74d-4847-824b-f173f3489a87/tfexplains-profile.jpg" width="40px" /> This page contains working examples for all supported quantifiers in Notion regular expressions. Duplicate this page to your workspace if you’re unable to view the formulas.

Regular Expressions in Notion Formulas

Created by Thomas Frank | Learn Notion Formulas | Notion Basics | Templates | Twitter

</aside>

πŸ“š References:


Character Escapes

Character Classes

Quantifiers

Anchors

Character Grouping

Substitutions

Backreferences

Alternation


Unicode Numbers in Regular Expressions


Regular Expression Examples


Notion Formula Examples


πŸ“œ Table of Contents:


* - match zero or more of the preceding character

replaceAll("Trs Tres Trees Treeeeees", "Tre*s", "🌳")
// Output: 🌳 🌳 🌳 🌳

replaceAll("Trs Tres Trees Treees Treeees", "Tr(ee)*s", "🌳")
// Output: 🌳 Tres 🌳 Treees 🌳

Test

+ - match one or more of the preceding character

replaceAll("Trs Tres Trees Treeeeees", "Tre+s", "🌳")
// Output: Trs 🌳 🌳 🌳

replaceAll("Trs Tres Trees Treees Treeees", "Tr(ee)+s", "🌳")
// Output: Trs Tres 🌳 Treees 🌳

Test

? - preceding character is optional; match zero or one of it

replaceAll("Trs Tres Trees Treeeeees", "Tre?s", "🌳")
// Output: 🌳 🌳 Trees Treeeeees

replaceAll("Trs Tres Trees Treees Treeees","Tr(ee)?s","🌳")
// Output: 🌳 Tres 🌳 Treees Treeees

Test

?? - match preceding character zero or one times (as few times as possible)

replaceAll("Trs Tres Trees Treees Treeees", "Tre??s", "🌳")
// Output: 🌳 🌳 Trees Treees Treeees

replaceAll("Trs Tres Trees Treees Treeees", "Tr(ee)??s", "🌳")
// Output: 🌳 Tres 🌳 Treees Treeees

Test

+? - match preceding character one or more times (as few times as possible)

replace("Tree", "Tre+?", "🌳")
// Output: 🌳e

Test

*? - match preceding character zero or more times (as few times as possible)

replace("Heeeeeeelp", "H.*?", "*")
// Output: *eeeeeeelp

replace("Heeeeeeelp", "H.*?l", "*")
// Output: *p

Test

{n} - match the preceding character n times

replace("Heeeeeeelp", "e{7}", "*")
// Output: H*lp

Test

{n,} - match the preceding character n or more times

replace("Heeeeeeelp", "e{1,}", "*")
// Output: H*lp

Test

{n,m} - match the preceding character between n and m times (inclusive)

replace("Heeeeeeelp", "e{1,6}", "*")
// Output: H*elp

Test

{n}? - match the preceding character n times (no difference from {n}

replace("Heeeeeeelp", "e{1,}?", "*")
// Output: H*eeeeeelp

Test

{n,}? - match the preceding character at least n times, but as few times as possible

replace("Heeeeeeelp", "e{1,}?", "*")
// Output: H*eeeeeelp

Test

{n,m}? - match the preceding character at least n times, no more than m times, and as few times as possible

replace("Heeeeeeelp", "e{1,6}?", "*")
// Output: H*eeeeeelp

Test


Β© Thomas Frank