<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 character grouping/capturing methods 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:


() - capture group (is automatically assigned a sequential reference number)

replace("Dog Blog", "(Dog) Blog", "$1")
// Output: Dog

replace("Dog Blog", "(Dog) (Blog)", "$2")
// Output: Blog

replaceAll("Jack Sparrow", "^(\\\\w+)\\\\b.*", "$1")
// Output: Jack

Test

(?<name>expression) - named capture group

replace("Jack plays poker", "(?<sup>J).*(oker)", "$<sup>$2")
// Output: Joker

// Named capture groups are still assigned their sequential number
// Note the output when I reference "$<sup>$1" instead of "$<sup>$2"
replace("Jack plays poker", "(?<sup>J).*(oker)", "$<sup>$1")
// Output: JJ

Test

(?:) - non-capturing group

replace("Jack", "(?:Jack)", "$1")
// Output: $1

replace("123", "(\\\\w)(?:\\\\w)(\\\\w)", "$2")
// Output: 3

Test


© Thomas Frank