Skip to content
Kuovonne's Guide to Airtable
  • Pages
    • Kuovonne's Guide to Airtable
      • Fields
        • Overview of fields types
          • Editable Field Types
          • Computed Field Types
          • Field Types by Formula Data Type
          • Field Types in Scripting
        • Specific field types
          • Formula fields
            • Demystifying Formulas (DareTable 2022)
          • Rollup fields
          • Select fields
          • Attachment fields
            • Uploading Attachments
            • Attachment Size
            • Attachment URLS
            • Thumbnails
        • Converting Field Types
        • Naming fields
        • Metadata fields
          • Simple Metadata Fields
          • Data Validation
          • Additional Dependencies
          • Original Record URL (Thumbprint) Field
          • Column Divider Fields
          • DareTable 2023 Presentation
        • Field dependencies
      • Formulas
        • Formula Field Reference
        • Writing Formulas
          • Using AI to Write Formulas
          • General tips for writing formulas
          • Testing for Blank Values
          • Drafting Formulas in Parts
          • Function versus Operator
          • Typing Special Characters
          • Commenting Formulas
          • Formulas to avoid
        • Formatting Formulas
          • Basic Rules
          • Nested IF formulas
          • SWITCH Formulas
          • Operators
        • Specific Formulas
          • Ranges of Numbers Values
          • Comma Separated List of Fields Values with Optional Fields
          • Earliest / latest date across columns
          • List Fields Values (one per line) with Optional Fields
          • Rounding a date to the half year
          • Url of Interface Page for a record
          • Removing varying items from a list
        • Data Type Conversion in Formulas
          • Text to Numbers
          • Numbers to Text
          • Data type conversions with Dates
        • Troubleshooting Formulas
          • Formulas that won't save
          • Hiding or showing #ERROR!
          • Troubleshooting date/time/duration formulas
          • Troubleshooting numeric formulas
          • Troubleshooting formulas with lookups
          • Troubleshooting text formulas
      • Automations
        • Triggering automations
          • Triggering automations for typed values
          • Triggering automations on existing records
        • Sending Emails
          • Ways to send emails
          • Using links in emails
          • Emailing Attachments
        • Accessing updated record values
        • Third party automations
        • Managing automation runs
      • Templates
        • Templates for record values
        • Templates using field values
      • Controlling Access
        • Sharing a base
        • Access control considerations
        • Techniques for limited access
          • Airtable interface
          • Share link access
          • Synced table
          • Prefilled forms + Automations
          • 3rd party portal
          • 3rd party webhook
        • Preventing base duplication
      • Specific Solutions
        • Most recent form submission for ermail
        • Email digest of a person’s records
        • Sum of Multiple Select choices
        • Link to multiple records based on select choices
        • Dropping Lowest Score (top 4 of 5)
        • Identify the position of a record in a linked record field (top 4 of 6)
        • Sequential Numbering of Records
        • Ending a list of rollup items with ", and"
        • Table ID in a formula
        • Latest/earliest date across several fields
        • Associating People with Records
        • First Tuesday of the Previous Month
      • Miscellaneous
        • Web API Calls for External Integrations
        • Getting paid to work with Airtable
        • Hiring a consultant
        • Airtable Communities
        • Making major changes to a base
      • Suggestion for this guide

Removing varying items from a list

Thank Kuovonne for creating this content!

Inspiration

In in the Airtable community, the author has two text strings of words, and wants to remove all the words that appear in the second list from the first list.
image.png

Discussion

Introducing the pipe character to separates choices

To separate different choices in RegEx, use the pipe character | between the choices.
image.png
image.png
This gets close to the desired results with a few extra commas and spaces. We’ll take care of those later.

Converting {List B} to use Pipes

To get {List B} to look like the expression with pipes, we can replace the commas and spaces with pipes.
image.png
image.png
image.png
Since we don’t really need to do anything with the {List B with Pipes} field, we can nest it inside the {RegEx} formula field.
image.png

Deleting the extra commas and spaces

You may be tempted to use SUBSTITUTE() to replace the repeated commas and spaces, but we don’t want to replace all the commas, only the extra ones, and there might be more than one extra one. Instead, use RegEx to replace repeated comma and spaces with a single comma and space.
image.png
image.png
image.png
Let’s consolidate all the formulas together.
image.png

Testing cases with partial matches

Notice that any occurrence of a phrase in {List B} is removed from {List A}, even if it is only a part of the phrase in {List A}. To avoid this problem and only remove complete matches, we need to use delimiters around the entire phrases so that the expression can tell where phrases begin and end. I use curly braces as delimiters because they do not appear in either of the original lists and are not REGEX control characters.
image.png
image.png
image.png
When consolidating the formulas, the end result was too long to fit nicely in a single screen capture, so I am not including it. However, you can use the same nesting technique to consolidate them.

Additional considerations

The field types of {List A} and {List B} might be lookup fields for the person posting in the community. In that case, the commas do not actually exist, and a slightly different approach might be necessary.
If the original fields are lookups, I would convert them to rollup fields, and include the delimiters in the rollup formula. ​
image.png
Thank Kuovonne for creating this content!
Want to print your doc?
This is not the way.
Try clicking the ··· in the right corner or using a keyboard shortcut (
CtrlP
) instead.