<aside> <img src="https://s3-us-west-2.amazonaws.com/secure.notion-static.com/a5a1e3ce-00fa-46e4-9a75-58c2aed9e8ce/Notion_Fundamentals_with_Thomas_Frank_-_Avatar_2021.png" alt="https://s3-us-west-2.amazonaws.com/secure.notion-static.com/a5a1e3ce-00fa-46e4-9a75-58c2aed9e8ce/Notion_Fundamentals_with_Thomas_Frank_-_Avatar_2021.png" width="40px" /> The example database below contains several media attachments. The File Extension property uses replace() and a regular expression to replace each file’s full URL with its file extension.

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

</aside>

File Extensions

replace(prop("File"), ".*\\\\.(\\\\w+)$", "$1")

Example Database 2: Temperature Conversion

<aside> <img src="https://s3-us-west-2.amazonaws.com/secure.notion-static.com/a5a1e3ce-00fa-46e4-9a75-58c2aed9e8ce/Notion_Fundamentals_with_Thomas_Frank_-_Avatar_2021.png" alt="https://s3-us-west-2.amazonaws.com/secure.notion-static.com/a5a1e3ce-00fa-46e4-9a75-58c2aed9e8ce/Notion_Fundamentals_with_Thomas_Frank_-_Avatar_2021.png" width="40px" /> The example database below shows how you can use replace() in conjunction with other functions to convert a temperature value from Fahrenheit to Celsius.

At first, the temperature is a string value that cannot be manipulated by arithmetic functions. replace() is used to extract the number from the full string.

</aside>

Temperature Conversion

// Compressed
replace(replace(prop("Name"),"\\\\d+",format(round((toNumber(replace(prop("Name"), "\\\\D*(\\\\d+)\\\\D", "$1")) - 32) * 5 / 9))),"°F","°C")

// Expanded
replace(
    replace(
        prop("Name"),
        "\\\\d+",
        format(
            round(
                (
                    toNumber(
                        replace(
                            prop("Name"), 
                            "\\\\D*(\\\\d+)\\\\D", 
                            "$1"
                        )
                    ) - 32
                ) * 5 / 9
            )
        )
    ),
    "°F",
    "°C"
)

© Thomas Frank