For each value in an array, if found in output then replace it with the found value and a linebreak

289 views Asked by At

I am trying to create a flow in PowerAutomate which iterates through each value in an array (each value is present somewhere in the output), and replaces the found value with itself and a linebreak. Essentially, adding a linebreak at each value from the array, in the output.

For instance, I might have the array: 1, 2, 3

And the input: Hello 1 nice 2 see you 3 today

I would like here to get the output: Hello
1 nice
2 see you
3 today

I have tried with apply to each and everything. But I just can't seem to find a "ReplaceALL" function or anything of the sort in powerautomate ):

Any help is appreciated.

1

There are 1 answers

0
Expiscornovus On

You could use a Select action for this.

Below is to demonstrate how you could check the value of the item has a certain value.

if(equals(item(), 1), concat(item(), ' nice'), if(equals(item(), 2), concat(item(),' see you'), concat(item(), ' today')))

After that you can join them together with a line feed character.

concat('Hello',decodeUriComponent('%0A'),join(body('Select'), decodeUriComponent('%0A')))

enter image description here