I’m trying to extract a substring from a file name using base formulas. The substing is a date in the format yyyy-MM-dd, so I can easily match it with the regex /\d{4}-\d{2}-\d{2}/.
Looking into the base documentation I’ve found the matches() function, which only tells me if the string matches the pattern.
To extract the pattern I was thinking to use replace() with regex lookahead/lookbehind, but it’s quickly turning me crazy
I once tried to achieve something similar, but ended up doing it differently because I could find a good solution.
There is currently no function that returns a matching string. With the replace() function you are also limited as replacementdoes only allow for a string, but not regex, so no access to capture groups.
A possible workaround can be the convert functions such as number() or date(). If you before use replace() function to remove all non date characters, it might work depending on your specific case.
To be fair, props to Claude. At the beginning it allucinated with some non existing functions, but also suggested me to use capture groups.
I’m guessing under the hood many base functions are just wrappers to regular js functions. Being not documented I hope it’s not a bug that will be solved sooner or later