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

Community site session details

Session Id :
Power Automate - Building Flows
Answered

How to remove/replace the start and the end of a string in flow?

(0) ShareShare
ReportReport
Posted on by 159

Hi, 

I am wondering how to remove/replace the start and the end of a string in flow?

I I have this string:

 

Base64ToString(
Title,Dato,Department
Test 1,2022-12-30,NY
Test 3,2022-12-31,PARIS
Test 5,2023-03-04,NY
Test 6,2023-07-01,LONDON
Test 2,2023-01-21,PARIS

)

 

How can I remove the "Base64ToString(" and ")", so that the string looks like this?

The reason I need this is because I need to export it as a csv-file.

 

Title,Dato,Department

Test 1,2022-12-30,NY
Test 3,2022-12-31,PARIS
Test 5,2023-03-04,NY
Test 6,2023-07-01,LONDON
Test 2,2023-01-21,PARIS

 

It needs to happen in flow. I tried using replace, but it didn't quite work maybe I wrote something wrong...?

 

Really appreciate the help!

I have the same question (0)
  • grantjenkins Profile Picture
    11,059 Moderator on at
    Re: How to remove/replace the start and the end of a string in flow?

    I've built a couple of options for you.

     

    I've used a variable called text that contains your data.

    grantjenkins_0-1672445484436.png

     

    You can use the following expression to remove the first and last lines, including the new line characters.

    replace(replace(variables('text'), concat('Base64ToString(', decodeUriComponent('%0A')), ''), concat(')', decodeUriComponent('%0A')), '')

     

    However, it looks like you actually want to extract the data, so you could actually do the following.

     

    See full flow below. I'll go into each of the actions.

    grantjenkins_2-1672445940313.png

     

    Initialize variable is what we had before - string variable called text that contains your full string.

    grantjenkins_8-1672446435980.png

     

    Compose splits the string by new line character to give you an array of strings. We also use skip to exclude the first two rows. The expression used is.

    skip(split(variables('text'), decodeUriComponent('%0A')), 2)

    grantjenkins_4-1672446050528.png

     

    Filter array then takes that data and removes any items that are ")" which is our last extra line. The expression used is:

    item()

    grantjenkins_5-1672446224377.png

     

    Finally, we have a Select that takes in the output from our Filter array and builds up each of the objects. Below are the expressions used:

    //Title
    split(item(), ',')?[0]
    
    //Date
    split(item(), ',')?[1]
    
    //Department
    split(item(), ',')?[2]

    grantjenkins_6-1672446321344.png

     

    After running the flow, we would get the following output from our Select.

    [
     {
     "Title": "Test 1",
     "Date": "2022-12-30",
     "Department": "NY"
     },
     {
     "Title": "Test 3",
     "Date": "2022-12-31",
     "Department": "PARIS"
     },
     {
     "Title": "Test 5",
     "Date": "2023-03-04",
     "Department": "NY"
     },
     {
     "Title": "Test 6",
     "Date": "2023-07-01",
     "Department": "LONDON"
     },
     {
     "Title": "Test 2",
     "Date": "2023-01-21",
     "Department": "PARIS"
     }
    ]

    grantjenkins_7-1672446386528.png


    ----------------------------------------------------------------------
    If I've answered your question, please mark the post as Solved.
    If you like my response, please consider giving it a Thumbs Up.

  • VictorIvanidze Profile Picture
    12,834 on at
    Re: How to remove/replace the start and the end of a string in flow?

    Show your flow. Where did you get "Base64ToString(..." ?

  • blinabj Profile Picture
    159 on at
    Re: How to remove/replace the start and the end of a string in flow?

    Hi @VictorIvanidze,

     

    I am adding it in order to read a csv file in Power Apps flow. If you know a better way to read it in flow I would be happy to here it 😀

     

    Hent filinnhold = Get file content

    blinabj_0-1672646349406.png

    Then, after this step, what I ideally want to do is create a new CSV file that looks like this (all in one column):

    blinabj_1-1672647438353.png

     

    So, the main goal with this flow is to format a CSV file and create a new file with the right format.

  • VictorIvanidze Profile Picture
    12,834 on at
    Re: How to remove/replace the start and the end of a string in flow?

    Please show the output of Komponer (Compose I guess) action.

  • blinabj Profile Picture
    159 on at
    Re: How to remove/replace the start and the end of a string in flow?

    Thanks for helping me @VictorIvanidze! The output of the Komponer/Compose is:

     

    Base64ToString(
    Title,Dato,Department
    Test 1,2022-12-30,NY
    Test 3,2022-12-31,PARIS
    Test 5,2023-03-04,NY
    Test 6,2023-07-01,LONDON
    Test 2,2023-01-21,PARIS

    )

     

    blinabj_0-1672655487865.png

    blinabj_1-1672655504503.png

     

     

  • VictorIvanidze Profile Picture
    12,834 on at
    Re: How to remove/replace the start and the end of a string in flow?

    Now please show the same action in edit mode.

  • blinabj Profile Picture
    159 on at
    Re: How to remove/replace the start and the end of a string in flow?

    @VictorIvanidze, that's the picture I showed you earlier:

     

    Hent filinnhold = Get file content

    Komponer = Compose

    blinabj_0-1672657688592.png

     

    The file that I am getting content from is saved on SharePoint and the content looks like this:

    blinabj_1-1672657755127.png

     

    So, my goal with this flow is to get this content, and make a new csv file with the content that looks like this:

    blinabj_2-1672657807346.png

     

     

  • VictorIvanidze Profile Picture
    12,834 on at
    Re: How to remove/replace the start and the end of a string in flow?

    It looks your compose action is wrong.  The Base64ToString is a function and you are using it as a prefix - for what?

  • blinabj Profile Picture
    159 on at
    Re: How to remove/replace the start and the end of a string in flow?

    @VictorIvanidze 

    I need the compose action in order to read the file content. If I don't use it, I only get some wired data information sentences. See picture below:

    blinabj_0-1672661887106.png

     

    I found the tip about using Base64ToString here:

    Solved: Re: How to read CSV file content from a file saved... - Power Platform Community (microsoft.com)

  • VictorIvanidze Profile Picture
    12,834 on at
    Re: How to remove/replace the start and the end of a string in flow?

    Again:  Base64ToString is a function. Use it as a function.

    VictorIvanidze_0-1672662195115.png

     

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 797 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 425 Moderator

#3
developerAJ Profile Picture

developerAJ 319

Last 30 days Overall leaderboard