How to make a regex pattern compatible with Airtable?

Hey there, I’m trying to use a regex replace formula in Airtable and am struggling to adapt the pattern for it to work inside Airtable by escaping problematic characters.

(?<=\/d\/)[\w-]+

What do you want the regex formula to do? Can you describe it in English?

Note that Airtable REGEX functions use Google’s RE2 RegEx, which has doesn’t support all the features in most regex testers.

1 Like

I use substitution formula although it is long it works. Once you know what you could use substitute formula. I have 2 tables, one is configuration of what I am replacing, when and where rules and the second table is a roll up table that pulls all the individual substitutions into the result formula field. That way putting long substitution formulas is zero effort:

example:

SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(FIELD_WITH_TEXT_I_NEED_TO_PROCESS___,‘0"’,‘0 inch’),‘1"’,‘1 inch’),‘2"’,‘2 inch’),‘3"’,‘3 inch’),‘4"’,‘4 inch’),‘5"’,‘5 inch’),‘6"’,‘6 inch’),‘7"’,‘7 inch’),‘8"’,‘8 inch’),‘9"’,‘9 inch’),“Aren’t”,“Are not”),“aren’t”,“are not”),“Aren’t”,“Are not”),“aren’t”,“are not”),“Can’t”,“Cannot”),“can’t”,“cannot”),“Can’t”,“Cannot”),“can’t”,“cannot”),“Didn’t”,“Did not”),“didn’t”,“did not”),“Didn’t”,“Did not”),“didn’t”,“did not”),“Doesn’t”,“Does not”),“doesn’t”,“does not”),“Doesn’t”,“Does not”),“doesn’t”,“does not”),“Don’t”,“Do not”),“don’t”,“do not”),“Don’t”,“Do not”),“don’t”,“do not”),“Hadn’t”,“Had not”),“hadn’t”,“had not”),“Hadn’t”,“Had not”),“hadn’t”,“had not”),“Hasn’t”,“Has not”),“hasn’t”,“has not”),“Hasn’t”,“Has not”),“hasn’t”,“has not”),“Haven’t”,“Have not”),“haven’t”,“have not”),“Haven’t”,“Have not”),“haven’t”,“have not”),“He’d”,“He would”),“he’d”,“he would”),“He’ll”,“He will”),“he’ll”,“he will”),“He’s”,“He is”),“he’s”,“he is”),“He’d”,“He would”),“he’d”,“he would”),“He’ll”,“He will”),“he’ll”,“he will”),“He’s”,“He is”),“he’s”,“he is”),“I’m”,“I am”),“i’m”,“I am”),“I’m”,“I am”),“i’m”,“I am”),“Isn’t”,“Is not”),“isn’t”,“is not”),“Isn’t”,“Is not”),“isn’t”,“is not”),“It’d”,“It would”),“it’d”,“it would”),“It’ll”,“It will”),“it’ll”,“it will”),“It’s”,“It is”),“it’s”,“it is”),“It’d”,“It would”),“it’d”,“it would”),“It’ll”,“It will”),“it’ll”,“it will”),“It’s”,“It is”),“it’s”,“it is”),“Mustn’t”,“Must not”),“mustn’t”,“must not”),“Mustn’t”,“Must not”),“mustn’t”,“must not”),“She’d”,“She would”),“she’d”,“she would”),“She’ll”,“She will”),“she’ll”,“she will”),“She’s”,“She is”),“she’s”,“she is”),“She’d”,“She would”),“she’d”,“she would”),“She’ll”,“She will”),“she’ll”,“she will”),“She’s”,“She is”),“she’s”,“she is”),“Shouldn’t”,“Should not”),“shouldn’t”,“should not”),“Shouldn’t”,“Should not”),“shouldn’t”,“should not”),“They’d”,“They would”),“they’d”,“they would”),“They’ll”,“They will”),“they’ll”,“they will”),“They’re”,“They are”),“they’re”,“they are”),“They’ve”,“They have”),“they’ve”,“they have”),“They’d”,“They would”),“they’d”,“they would”),“They’ll”,“They will”),“they’ll”,“they will”),“They’re”,“They are”),“they’re”,“they are”),“They’ve”,“They have”),“they’ve”,“they have”),“Wasn’t”,“Was not”),“wasn’t”,“was not”),“Wasn’t”,“Was not”),“wasn’t”,“was not”),“We’d”,“We would”),“we’d”,“we would”),“We’ll”,“We will”),“we’ll”,“we will”),“We’re”,“We are”),“we’re”,“we are”),“We’d”,“We would”),“we’d”,“we would”),“We’ll”,“We will”),“we’ll”,“we will”),“We’re”,“We are”),“we’re”,“we are”),“Weren’t”,“Were not”),“weren’t”,“were not”),“Weren’t”,“Were not”),“weren’t”,“were not”),“Woudn’t”,“Would not”),“woudn’t”,“would not”),“Woudn’t”,“Would not”),“woudn’t”,“would not”),“You’d”,“You would”),“you’d”,“you would”),“You’ll”,“You will”),“you’ll”,“you will”),“You’re”,“You are”),“you’re”,“you are”),“You’ve”,“You have”),“you’ve”,“you have”),“You’d”,“You would”),“you’d”,“you would”),“You’ll”,“You will”),“you’ll”,“you will”),“You’re”,“You are”),“you’re”,“you are”),“You’ve”,“You have”),“you’ve”,“you have”),“'s”,“”),“’s”,“”),“'”,“”),“’”,“”),‘"’,‘’),““”,“”),“””,“”)," “,” “),”―“,”-“),”,“,”.“),”?“,”“),”/“,”-“),”\n"," “),”•“,”-“),”|“,”"),“Ä”,“A”),“ä”,“a”),“C°”,“C”),“Cå¡”,“C”),“CŒÁ”,“C”),“F°”,“F”),“Få¡”,“F”),“FŒÁ”,“F”),“Ö”,“O”),“ö”,“o”),“Ü”,“U”),“ü”,“u”)

Apologies, I wrote replace when I’m actually extracing, causing confusion @itoldusoandso. :frowning:

I have a link field with Google Docs URLs from which I’m hoping to extract the file ID as shown in the initial screenshot.

I thought I would need to escape certain characters, but may also meet the limitations of the functions @Kuovonne mentioned.

Will your URLs always start with https://docs.google.com/document/d/ and end with /edit?

If so, that should be a very easy formula that uses the MID() function, along with the LEN() function and the FIND() function. You wouldn’t need to use REGEX for that.

However, for other REGEX needs, the link below is supposed to be an AI tool that converts plain English queries into REGEX code, although I’m not sure if you can specify that it only use Google’s REGEX library. I’ve also never used this tool, so I have no idea how well it works:

https://www.autoregex.xyz/

Unfortunately, they’re not homogenous and elemens prior to and after the ID vary from each other.

Thanks @ScottWorld I asked the AI too to use Google’s RE2 RegEx and the regex tester shows it’s workable (/https:\/\/docs\.google\.com\/document\/d\/([-\w]+)\//) but I failed to get it work in the Airtable formula.

This appears more complicated than expected to achieve in Airtable and I’m reverting to Make.com. :wink:

Yeah, you need to know the range of possible patterns before you can write a regex expression.