Skip to main content

Regex in Airtable is so frustrating. Help with string.

  • January 18, 2023
  • 3 replies
  • 104 views

Forum|alt.badge.img+7

I wish Airtable Regular expressions followed some common flavours so we could test it with regex101.com

I can make it work in these builders, but then when it comes back to Airtble #ERRROR. It's a huge potential but otherwise Airtable makes it hard to figure out why it isn't working.

I am trying to pull out the Patient's name from a Text extract. It always occurs after "Patient's name: " & before "Birthdate:"

Example string:
Radiology Report Patient’s name: Barney (57493) Birthdate: 7/5/2013 

One Regex101.com, and regextester.com I can get it perfectly with this regex:
(?<=name: )(.*)(?= Birthdate: )

But when I put that in airtable:

REGEX_EXTRACT({PDF Text Extraction}, "/(?<=name: )(.*)(?= Birthdate: )")
 
I get a big fat #ERROR
 
I know it's me but can anyone point me int he direction of a regex tester that is compatible with Airtable?
Or tell me what I can use here?

3 replies

Matthew_Lanni
Forum|alt.badge.img+18
This should do the trick, I think: REGEX_EXTRACT({PDF Text Extraction}, "Patient's name: (.*?) Birthdate:")
 
As for testing, I find that Google Sheets gives far better error messages and uses the same syntax (as far as I've seen), so that's what I use to figure it out before putting it into Airtable.

kuovonne
Forum|alt.badge.img+29
  • Brainy
  • January 18, 2023

Airtable REGEX formula functions are based on Google's RE2 library, which does not support the before/after features you are trying to use, among other things. It is the same library that Google Sheets uses.

If you stick to "simpler" regex expressions you should be okay. 


Forum|alt.badge.img+6
  • Participating Frequently
  • April 6, 2023

Something as simple as this fails in Airtable:

REGEX_MATCH('123','/^\\d{3}$/')

very frustrating indeed