web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / how do i remove /n/n i...
Power Automate
Answered

how do i remove /n/n in array from power automate

(0) ShareShare
ReportReport
Posted on by 403

My flow:

Jupyter123_0-1676261964169.png

My flow looks like this

Jupyter123_1-1676262002358.png

Jupyter123_5-1676262026739.pngJupyter123_6-1676262039152.pngJupyter123_7-1676262071833.png

As you can see, the response that im getting from "text" it has 2 new line characters
how do i remove those 2 new lines?

Jupyter123_8-1676262118737.pngJupyter123_9-1676262138073.png

 

Categories:
I have the same question (0)
  • Verified answer
    v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @Jupyter123 ,

     

    I've made a test for your reference:

     

    vbofengmsft_2-1676267432817.png

    {
     "text": @{replace(item()['text'],decodeUriComponent('%0A'),'')},
     "index": @{item()['index']},
     "finish_reason": @{item()['finish_reason']}
    }

     

    vbofengmsft_0-1676267404677.png

     

    Best Regards,

    Bof

     

  • Jupyter123 Profile Picture
    403 on at

    hi @v-bofeng-msft , thanks for the reply

    it worked, cheers

  • dperez13 Profile Picture
    432 on at

    how do i trim an array thats like this

    [ "a\n",

    "b\n\n\n",

    "c\n\n\n\n"

    ]

    i want to get rid of the linebreaks so i can iterate over each piece cleanly

  • Jupyter123 Profile Picture
    403 on at

    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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 304

#2
David_MA Profile Picture

David_MA 245 Super User 2026 Season 1

#3
Expiscornovus Profile Picture

Expiscornovus 243 Most Valuable Professional

Last 30 days Overall leaderboard