New: REGEX formula functions

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

I’d just REGEX REPLACE for this to match everything but the first letter and replace it with “”. As follows:

REGEX_REPLACE({Field},"[a-z]+[a-z\s]","")

This matches whole words, minus the first character
REGEX_REPLACE({Field},’(\B\w)*’,’’)

But yes, none of the REGEX commands use the global flag and will stop at the first match

I’m getting an error using REGEX_REPLACE even though the formula works on regex101. I’m trying to add or to the last item in a series.

My formula in Airtable:
REGEX_REPLACE(String,"/,(?=[^,]*$)",", or")

Any ideas?

Welcome to the community, @jj23! :smiley: When testing on Regex101, you need to use the Golang variant (originally labeled “RE2” when these functions were first released), which apparently doesn’t support the “?=” syntax. The “PCRE2” variant where this does work is apparently not the same variant of RE2 as the Golang version.

As a side note, you don’t need to copy the opening forward slash (or, for Golang, the graves). Those surrounding symbols are only required when pasting the regex directly into the relevant scripting language. For Airtable, you’re passing the regex as a string, so it doesn’t need the extra formatting characters.

After a little fiddling, I got this to work:

REGEX_REPLACE(String, ",([^,]*$)", ", or$1")

Screen Shot 2021-05-06 at 9.26.12 PM

4 Likes

Absolutely glorious @Justin_Barrett , thank you. Now my “Artists” field displays beautifully:

“Sunchase, NickBee & Teddy Killerz”

@Russell_Bishop1 Thanks, but props go to @jj23 for working out most of the regex. My cleanup work was minimal by comparison.