hey @dperez13
In Power Automate, you can use the 'Initialize variable', 'Apply to each', and 'Set variable' actions to process the array and remove the line breaks from each element.
Here's a step-by-step guide to accomplish this:
Create a new flow and add a 'Manual trigger' to start the flow.
Initialize an array variable to store the cleaned values. Add an 'Initialize variable' action, name it 'CleanedArray', and set the type to 'Array'.
Add an 'Apply to each' action to iterate over the input array. For the 'Select an output from previous steps' field, use the array you provided in your question:
[
"a\n",
"b\n\n\n",
"c\n\n\n\n"
]
Inside the 'Apply to each' action, add a 'Compose' action. In the 'Inputs' field, use the following expression to remove line breaks from the current item:
replace(items('Apply_to_each'),'\n','')
This expression uses the replace function to replace all occurrences of the newline character (\n) with an empty string.
Next, add a 'Set variable' action inside the 'Apply to each' action. For the 'Name' field, choose the 'CleanedArray' variable. For the 'Value' field, use the following expression to append the cleaned item to the 'CleanedArray' variable:
union(variables('CleanedArray'), array(outputs('Compose')))
This expression uses the union function to merge the current value of the 'CleanedArray' variable and the cleaned item into a new array.
After the 'Apply to each' action, you can use the 'CleanedArray' variable for any subsequent actions in your flow.
Now, when you run the flow, the 'CleanedArray' variable will contain an array with the line breaks removed:
[ "a", "b", "c"]
You can then iterate over this cleaned array for further processing in your flow.