Help

New: REGEX formula functions

cancel
Showing results for 
Search instead for 
Did you mean: 
Jason
Airtable Employee
Airtable Employee

regex_functions

Hello everyone! We recently launched some exciting new additions to our formula field with three new regex (regular expression) functions:

  1. REGEX_MATCH(string, regex)
  2. REGEX_EXTRACT(string, regex)
  3. REGEX_REPLACE(string, regex, replacement)

These functions can be used to match character combinations within text strings. For those interested, Airtable’s REGEX functions are implemented using the RE2 regular expression library.

You can learn more about these functions in this article or check out some example use cases shared in the posts below.

50 Comments
Russell_Bishop1
8 - Airtable Astronomer
8 - Airtable Astronomer

This is so helpful for preventing Automations throwing errors!

ZYGOTE_DEVELOPM
5 - Automation Enthusiast
5 - Automation Enthusiast

Is it possible to extract an entire URL from a larger block of text using this formula?

Justin_Barrett
18 - Pluto
18 - Pluto

Not that exact formula, but if you do a web search for “regex extract url” there are lots of options that come up. However, they would need to be tested to find one that works with the flavor of Regex used by Airtable. Sadly I don’t have time to test, so I can’t offer a more specific solution.

Jason_Woodruff1
4 - Data Explorer
4 - Data Explorer

Hi,
Wondering if REGEX_REPLACE could handle replacing mid-sentence new lines with “”. The solutions I have use look behind or possession (neither supported by RE2), or replacement with capture groups (not supported by REGEX_REPLACE sfaik).

Jason_Woodruff1
4 - Data Explorer
4 - Data Explorer

ha, ha, capture groups do work!

REGEX_REPLACE(Text,"(\\S)[ \\t]*(?:\\r\n|\n)[ \\t]*(\\S)","$1 $2")

Greg_Joyce
4 - Data Explorer
4 - Data Explorer

Hm. I seem to be getting some unexpected results. Could be my regex game is weak.

Formula:

REGEX_REPLACE(REGEX_REPLACE('-- --  ---', '\\s+','x'), '-+','y')

Expectation:

yxyxy

Result:

yxy xy

Or with the more concise

    REGEX_REPLACE('-- --  ---', '\\s+','x')

Result:

   --x-- x---
kuovonne
18 - Pluto
18 - Pluto

@Greg_Joyce I get your “expected result” when I create a formula field with your formula.

Matt_Coppernoll
4 - Data Explorer
4 - Data Explorer

Can’t get REGEX_EXTRACT to work as expected when trying to extract multiple things from a string. My goal is to extract Initials from a Name field. So “John Smith” would extract “JS”.

I’ve verified all these Regex works with an online tester, but can’t get them to work in Airtable:

REGEX_EXTRACT(Name,"\b(\w)")

REGEX_EXTRACT(Name,"(\b[a-zA-Z])[a-zA-Z]* ?")

REGEX_EXTRACT(Name,"([[:alpha:]])[[:alpha:]]+")

Value of Name:
“John Smith”

Current results:
“J”

Expected results:
“JS”

dilipborad
9 - Sun
9 - Sun

You need to write 2 expressions and merge them like this.
REGEX_EXTRACT({Name},"^(.{1})") & REGEX_EXTRACT({Name},"\\s+([a-zA-Z]){1}")

I hope this is works for you.

kuovonne
18 - Pluto
18 - Pluto

In Airtable, REGEX_EXTRACT extracts only the first match, not all matches.