Dictionary Style Replacements (replace a list of terms)

Hello Community!

I am looking for a way to do a full set of text replacements inside of a table. “RegexReplace()” works well for individual terms or if a list of terms is all turning into the same thing (eg. “apple|blueberry|kiwi” :arrow_right: “fruit”), but thus far I haven’t figured out how to do it from a list of terms to a list of terms.

Likewise, due to the existing implementation of FormulaMap() (see: Simulate a For Loop (Reference position inside FormulaMap)), there is no way to “carry forward” a variable, so while I can use it to iterate through my terms and replace each, but then I just end up with a list of my original description with each single replacement.

I need help thinking through how to appropriately split up the original description, run the necessary replacements, and join it all back together. I know this could be easily done with an Excel macro, but I’m attempting to have Coda interpret the raw data completely.

Finally, I do recognize this can be accomplished with buttons (example included below), but would ideally like to make it happen via formula; since replace terms will be added and changed, I wouldn’t want to reset the entire legacy dataset each time.

Here is a reduced sample:

Loop with formulaMap, as you found out, has the drawback of not allowing external modifications during the loop. I should update that post.

This one is a bit more to the case:

What you need is a button loop then. This doc suggests a starting point (next step would be adding a reset logic).

1 Like

Thanks @Dalmo_Mendonca, yeah, it makes sense that if I can’t use a formula to accomplish my end goal, your method here of looping button presses will be the best way forward, thanks!

1 Like