contains
Learn how to use the contains function in Notion formulas.
The contains() function tests whether the first argument contains the second argument. It only accepts strings (or nested functions that output strings).
1
contains(string)
contains() tests for the entire string passed via the second argument, is case-sensitive, and does not accept regular expressions.
Good to know: The test function can do everything contains() does and much more, including accepting regular expressions and testing non-string data types.

1
contains("Monkey D. Luffy", "Luffy") // Output: true
2
โ€‹
3
contains("Monkey D. Luffy", "keyLuf") // Output: false
4
โ€‹
5
// Invalid
6
contains(true, "true") // Error: Type mismatch true is not a Text.

This example database contains some file attachments. The Meta formula property displays information about each file, including its media type and hosting location (within Notion or hosted externally).

contains
College Info Geek on Notion

1
// Compressed
2
if(contains(prop("File"),"jpg") or contains(prop("File"),"png") or contains(prop("File"),"gif") or contains(prop("File"),"jpeg"),"๐ŸŒ… Image",if(contains(prop("File"),"mp3") or contains(prop("File"),"wav") or contains(prop("File"),"aiff"),"๐ŸŽง Audio","๐Ÿ“ Text")) + "\n" + if(contains(prop("File"),"secure.notion-static.com"),"โœ… Internal","โ›”๏ธ Externally Hosted")
3
โ€‹
4
// Expanded
5
if(
6
contains(
7
prop("File"),
8
"jpg"
9
) or contains(
10
prop("File"),
11
"png"
12
) or contains(
13
prop("File"),
14
"gif"
15
) or contains(
16
prop("File"),
17
"jpeg"
18
),
19
"๐ŸŒ… Image",
20
if(
21
contains(
22
prop("File"),
23
"mp3"
24
) or contains(
25
prop("File"),
26
"wav"
27
) or contains(
28
prop("File"),
29
"aiff"
30
),
31
"๐ŸŽง Audio",
32
"๐Ÿ“ Text"
33
)
34
) +
35
"\n" +
36
if(
37
contains(
38
prop("File"),
39
"secure.notion-static.com"
40
),
41
"โœ… Internal",
42
"โ›”๏ธ Externally Hosted"
43
)
File & Media-type properties return their file path as a string when referenced in Notion formulas.
This formula uses contains() to check each fileโ€™s path for the presence of several common file extensions, such as jpg, gif, mp3, etc.
It uses a nested if statement , as well as the or operator, to check for several different file extensions. It then outputs the fileโ€™s media type based on its match (or lack thereof).
Another if statement checks for the presence of the string secure.notion-static.com, which is always part of the URL for files that are uploaded directly to Notionโ€™s Amazon AWS locker.
Note: One major weakness of contains() is that it canโ€™t do case-insensitive matching. In this formula, weโ€™d have to add many more โ€œorโ€ clauses in order to test for every case variation of each file type. Check out the test functionโ€™s example database to see a much more efficient way to achieve this exact same goal.

โ€‹
My name is Thomas Frank, and I'm a Notion-certified writer, YouTuber, and template creator. I've been using Notion since 2018 to organize my personal life and to run my business and YouTube channel. In addition to this formula reference, I've created a free Notion course for beginners and several productivity-focused Notion templates. If you'd like to connect, follow me on Twitter.
Last modified 21d ago
Copy link
On this page
Example Formula
Example Database
View and Duplicate Database
โ€œMetaโ€ Property Formula