Finding and replacing text
  • 08 Nov 2023
  • 5 Minutes to read
  • Dark
  • PDF

Finding and replacing text

  • Dark
  • PDF

Article Summary

This article covers how to find and replace text within a string. Some common solutions using these functions will be reviewed as well. Here are the functions we'll discuss:

  • FIND

This article is part of a guided course which you can view here.


The FIND and SEARCH functions locate any character in a string of text and tells you where the first occurrence exists in that string. While SEARCH will only provide the character position if it finds one, FIND will provide the number zero if it finds nothing at all.

This makes FIND a better candidate for most formulas because it offers a result that will prevent multi-function formulas from displaying an error. Aside from that, and their names, these functions are otherwise identical. For simplicity, we'll focus on using FIND. Let's begin with an example string of text to work with:

Hello, world!

If you wanted to find the position of the comma in that string you'd just use the FIND function like this:

FIND  ( ","  ,  "Hello, world!"  )

In this case, the FIND function will provide the following result:


We get the number 6 because the comma in the example is the 6th character in that string of text. If we, instead, looked for the exclamation point the formula would provide the number 13 instead. A common use of FIND is to extract the file name from an attachment in a record using a formula like this:

LEFT  ({Attachment Field},FIND( "("  ,{Attachment Field})  -1 )


File names always follow the same structure in Airtable, and look like this:


We can therefore use FIND to identify a character in that file name string, like the opening parenthesis, as a sort of placeholder in order to extract only the file name from that entire string. Here's the formula again for easy reference:

LEFT({Attachment Field},FIND("(", {Attachment Field})-1)

FIND looks for the opening parenthesis and returns the number that it falls on within the string. LEFT then uses that number to know how many characters to extract from the entire string. This creates a dynamic way to always extract the right amount of character for any file name!

Note that this formula only accounts for attachment fields with a single file attached.


The REPLACE and SUBSTITUTE functions accomplish very similar but different tasks. Put simply, you use REPLACE to replace a single instance of some amount of text (e.g. a name) and you use SUBSTITUTE when you want to replace them all. Take this text string for example:

His name was George.

What if his name wasn't George but, rather, Billy? We can use the REPLACE function to fix that:

REPLACE("His name was George", 14, 6, "Billy")

That formula would provide the result we want:

His name was Billy

The SUBSTITUTE function can do the same thing:

SUBSTITUTE("His name was George", "George", "Billy")

In this case, using SUBSTITUTE makes more sense because George only appears once in the text and it doesn't require us to locate any exact character positions. If George appeared multiple times and we only wanted to change one instance of George to Billy, using REPLACE would make more sense.

You can use both functions on text fields in your base like this:

REPLACE({Text Field}, 14, 6, "Billy")
SUBSTITUTE({Text Field}, "George", "Billy")

SUBSTITUTE, on its own, will successfully replace every instance of George with Billy in every record using that text field. If it finds nothing, it will replace nothing and leave the text as-is.

REPLACE, on the other hand, will replace the characters at the specified location with Billy in every record. You probably won't want that and will need to locate where the first instance of George begins if you want to ensure consistent replacements. This formula meets those criteria:

REPLACE({Text Field}, FIND("George", {Text Field}), 6, "Billy")

In this case, we only need to find the starting location of George because we know the count will always remain the same. After all, George is and always will be a six letter name. When you want to replace a single instance some text, you only need one other function to do it consistently throughout all your records.

Nesting functions

In order to substitute out different values within the same formula, you're able to nest these functions similarly to how you would nest an IF statement.

For example, if you wanted to substitute out vertical pipes || for double forward slashes //, and periods . with commas , you could nest those two substitutions together in the same formula.

SUBSTITUTE(SUBSTITUTE ({Field Name}, "||" , "//" ),"." , "," )

Notice that only the inner-most function references the field name, while the outer function works by substituting the result of the function nested within it.

See the example below for a more dramatic example of a complex nested substitute formula.



While the formula above may look intimidating, it's actually quite straightforward. The inner-most function SUBSTITUTE({name},"%","%25") references the field where the target text exists. Then, each of the other nested functions above it substitute out text from the result of each of the functions within it.

Knowledge Check

Now that you know a bit about substitutions and nested functions, do you think you can solve this formula problem?

Problem :

You need to do a find and replace using the substitute formula string. In your {Product Names} field you have a bunch of product names. An example would be something like “LS Shirt” and "SL Shirt" but you need to change them to “Long Sleeve Shirt” and "Short Sleeve Shirt" instead.
How would you go about solving this with a formula? Below, you’ll find three formulas that might solve this problem. Click on the one that you think is correct to find out if you’re right.

SUBSTITUTE(SUBSTITUTE({Product Name}, "LS Shirt", "Long Sleeve Shirt"), "SL Shirt", "Short Sleeve Shirt")

🎉 Correct! This formula follows the correct structure shown in previous examples.

SUBSTITUTE(SUBSTITUTE({Product Name}, "LS Shirt", "Long Sleeve Shirt"), {Product Name}, "SL Shirt", "Short Sleeve Shirt")

🤔 Sorry, that's not the right one.

SUBSTITUTE(SUBSTITUTE({Product Name}, "LS Shirt", "Long Sleeve Shirt", {Product Name}, "SL Shirt", "Short Sleeve Shirt"))

🤔 Sorry, that's not the right one.

Formula Foundations

This article is part of a guided course that helps you learn how to use Airtable formulas.

View Course

Was this article helpful?