My end goal is to calculate the Flesch–Kincaid readability of a given text field ("Copy (Required)"). In order to do that, I need to determine how many syllables are in that text.
Syllabification is somewhat of a subjective thing, but the approach that I've chosen is to use a series of nested REGEX_REPLACE functions inside a formula field based on this approach from Guilherme D. Garcia. The resulting formula looks like this:
I know that Airtable’s REGEX functions are implemented using the RE2 regular expression library but I can't seem to get the syntax correct for the "replacement" string. For reference, here's the syntax for REGEX_REPLACE:
REGEX_REPLACE(string, regular_expression, replacement)
For example, in my innermost "replacement" I am specifying:
In plain english, this means we will replace whatever is matched with the same match + a hyphen, hence "\\1-". Number 1 here simply refers back to our matching group; since there’s only one group, we use "\\1".
MY PROBLEM: Specifying an EXPRESSION in the "replacement" text doesn't seem to work within Airtable. When I put make "\\1-" the replacement text parameter in REGEX_REPLACE it literally replaces it within that text instead of interpreting it as an EXPRESSION and replacing the matched text with the matched text + a hyphen.
MY QUESTION: Is Airtables REGEX_REPLACE function capable of accepting and processing EXPRESSIONS as the "replacement" parameter? If so, what's wrong with my syntax that I'm getting a literal replacement instead of an expression?
Expected Output (using formula above):