Search code examples
regexairtable

Airtable regular expression syntax in a formulae


I'm having dificulty extracting the filename from another cell. The regular expression I have works perfectly on regex101.com but only results in error on airtable.

My working regular expression has a non capturing group followed by everything else:- (?:[\\])(.*)

An example string I'm working with is Tech Stuff - Old Channels 💀 - image-assets [839605635295772672].csv_Files\IMG_0165-E23DF.JPG

Does airtable support regular expression groups and if so, what am I doing wrong.

My airtable formulae reads REGEX_EXTRACT( {Attachments}, '(?:[\\])(.*)') but results in error however REGEX_EXTRACT( {Attachments}, '[A-Za-z]*.[A-Za-z]*') gets me 'Tech Stuff' no problem but if I try REGEX_EXTRACT( {Attachments}, '(?>[A-Za-z]*)(.[A-Za-z]*)') I just get #ERROR


Solution

  • You may try:

    REGEX_EXTRACT({Attachments}, '[^\\\\]+\\.[^.]+$')
    

    The regex pattern here says to match:

    [^\\]+  a group on non backslash characters
    \.      dot
    [^.]+   the file extension
    

    Demo