Hey @Karlstens!
Airtable and regex have a strange relationship.
The functionality, as you’ve noticed, is limited.
In your situation, I can think of three possible solutions:
Nested Formula Oblivion
You’d pretty much just have to write a massive IF function.
If you pass this condition:
OR(
SEARCH(
LOWER(
{Player}
),
"keepWord1"
),
SEARCH(
LOWER(
{Player}
),
"keepWord2"
),
SEARCH(
LOWER(
{Player}
),
"keepWord3"
)
)
You’re doing the equivalent of this portion of your regex pattern:
(?!keepWord1|keepWord2|keepWord3)
I don’t even want to think about how dense the nesting would be for the next parameters of the formula.
Multiple Formula Fields
I’m not even sure I can properly think about how I would do it, but another idea would be to create a dedicated formula field to evaluate the big parts of what you’re trying to do.
You’d have a formula field to see if keepWord{1,3}
is present.
Then you’d need a formula field to look at the replaceWord{1,6}
values and evaluate whether the value exists.
If those two fields cooperate, you’d then have a final field that spits out the properly transformed string using either the SUBSTITUTE
or REGEX_REPLACE
functions.
Needless to say, this is also messy.
Scripting / Javascript
For your use case, I would actually recommend this method.
You’d just have an automation that looks at changes to the {Player}
field.
If the field returns a value, then evaluate the string against the regex pattern, and then write the transformed string into the field.
Again… none of it is ideal, but the scripting method is honestly pretty clean if you ask me.