<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 backreferences 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:


\\\\n - e.g. \\\\1 - backreference. Must match an existing capture group

replace("12-12-12", "([0-9]+)-\\\\1-\\\\1", "Success")
// Output: Success

replace("12-34-56", "([0-9]+)-\\\\1-\\\\1", "Success")
// Output: 12-34-56

replace("I have 56 apples, 35 bananas, and 35 grapes.", ".*(56).*(35).*\\\\2.*", "Success")
// Output: Success

Test

(?<name>\\\\w) \\\\k<name> - named backreference

replace("I have 56 apples, 35 bananas, and 35 grapes.", ".*(56).*(?<two>35).*\\\\k<two>.*", "Success")
// Output: Success

// Named backreferences can still be called with their sequential number
replace("I have 56 apples, 35 bananas, and 35 grapes.", ".*(56).*(?<two>35).*\\\\2.*", "Success")
// Output: Success

Test


© Thomas Frank