Find and replace: text to find is any item in a list of texts

Hi,

Let’s say I have in my DB this text: “qqq www eee rrr ttt”.
And I have this list: [“www”,“rrr”,“kkk”].

I want to find any word in the text that matches any item in the list (“www” and “rrr” in this case) and add () to them, so the text will be like this: “qqq (www) eee (rrr) ttt.”

The text is dynamic so its value can change. And the list is dynamic so the items and the count of these items can change.

Anything put in the text to replace of the :find & replace is considered one text, so putting (www,rrr,kkk) doesn’t work.

I am thinking of adding a loop that contains :find & replace to the workflow that stores the text, so the loop will add another edited text to another field.

Another solution is to make a workflow that includes the loop to store the edited text in a custom state.

But I am looking for a solution that doesn’t include a loop and workflow, so what do you think?

If you know javascript then you can use that in Javascript to bubble plugin & do the operation on the client side or server-side if you know NodeJS. Then store the results.