<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 classes 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:
Unicode Numbers in Regular Expressions
π Table of Contents:
\\\\w
- alphanumeric character<aside> π‘ Notion considers non-spacing marks to be non alphanumeric characters. Other regex engines (.NET, for example) do the opposite.
</aside>
Lowercase letters | a-z |
---|---|
Uppercase letters | A-Z |
Numbers | 0-9 |
Punctuation, Connector symbols | Notion only supports _ |
replaceAll("CAPS_nocap 12345", "\\\\w", "*")
// Output: ********** *****
\\\\W
- non-alphanumeric characterreplaceAll("correct horse battery staple", "\\\\W", "")
// Output: correcthorsebatterystaple
\\\\d
- digit character (0-9)replaceAll(id(), "\\\\d", "")
// Output: ddecdfeacb (where ID is dd68e1cdf20e4000962a0583cb007342)
\\\\D
- non-digit characterreplaceAll(id(), "\\\\D", "")
// Output: 1226438582411837830594 (where ID is 122643c8582b4c1183bccfe783e05f94)
\\\\s
- whitespace characterreplaceAll("charmander man bun", "\\\\sman\\\\s", " ")
// Output: charmander bun
\\\\S
- non-whitespace characterreplaceAll("charmander man bun", "\\\\Sman\\\\S", "ndl")
// Output: chandler man bun
.
- wildcard; matches any single character except newline (\\\\n
)replaceAll("And blimey, if it ain't mutton again today!", ".", "π‘")
// Output: π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘
// Include newlines using (.|\\\\n)
// Assume prop "TwoLines" contains:
// And blimey,
// if it ain't
// mutton again today!
replaceAll(prop("TwoLines"),"(.|\\\\n)","π‘")
// Output: π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘
[]
- character class (matches any single character included in the group)replaceAll("gold fold bold","[gfb]","t")
// Output: told told told
replaceAll("27 dresses","[a-z]","π")
// Output: 27 πππππππ
replaceAll("abcdefghijklmnopqrstuvwxyz123456789", "[a-ev-z1357-9]", "π")
// With commas:
replaceAll("abcdefghijklmnopqrstuvwxyz123456789", "[a-e,v-z,1,3,5,7-9]", "π")
// Output: πππππfghijklmnopqrstuππππππ2π4π6πππ
[^]
- negated character class (matches any single character not included in the group)replaceAll("123456789abcdefghijklmnopqrstuvwxyz", "[^a-z]", "")
// Output: abcdefghijklmnopqrstuvwxyz
replaceAll("abcdefghijklmnopqrstuvwxyz123456789", "[^cow]", "")
// Output: cow ("c","o","w" are in alphabetical order naturally. The character class doesn't specificy order.)
Β© Thomas Frank