Skip to main content

Notifications

Community site session details
Power Automate - Building Flows
Answered

is it possible to replace multiple strings in one replace function?

Like (0) ShareShare
ReportReport
Posted on 25 Aug 2017 06:58:26 by

Im running into the following problem:

 

Got a flow that creates folders in SharePoint from Accounts in CRM dynamics.

But in CRM it is possible to use special characters in the accountname.

 

When the flow gets triggered and a special character is used.

It fails because a folder name can`t contain one of these characters.

 

Example of invalid characters:

# % * : < > ? /  |

 

Im trying to replace these characters with @replace. But i dont know if its possible to replace all the characters in one function?

 

What i got now is:

 

replace(body('Account')['name'], '#, %, *, :, <, >, ?, /, |', '')

 

Please let me know if its possible

  • Community Power Platform Member Profile Picture
    on 19 Jul 2021 at 14:58:20
    Re: is it possible to replace multiple strings in one replace function?

    In this following link I found the most easy way to solve this problem
    Just follow the steps 😄 

    https://www.alanps1.io/power-platform/flow/flow-stripping-unwanted-characters-or-special-characters-from-a-string/

  • MK1 Profile Picture
    169 on 28 Jan 2019 at 21:08:10
    Re: is it possible to replace multiple strings in one replace function?

    @MichaelS66,

     

    can you please provide more details like how to use the function because, In my scenario i'm calling Flow From PowerApps and ParseJSOn is having an error below:

    Flow: Can you mention whwere to use the function on flow

    Step1: PowerApps

    Step2: ParseJson

    Step3:Compose

    Step4:Create File

    Step5: Respond To PowerApps

    InvalidJSON. The 'content' property of actions of type 'ParseJson' must be valid JSON. The provided value

     

    I'm not sure whether to use the function on a button from PowerApp or to use it in my Flow. Can you please provide more details.

     

    Thanks,

    MK1

  • GuillaumeP Profile Picture
    29 on 11 Jul 2018 at 08:52:18
    Re: is it possible to replace multiple strings in one replace function?

    hi,

     

    I've tried the multiple replace function since 1 hour but without found the exact syntax. Thank you !

  • MichaelS66 Profile Picture
    22 on 20 Jun 2018 at 11:28:35
    Re: is it possible to replace multiple strings in one replace function?

    You can use replace within replace. I used this to remove illegal character in email subject. Not pretty but it works.

    replace(replace(replace(replace(replace(replace(replace(replace(replace(triggerBody()?['Subject'],':',''),'%',''),'#',''),'*',''),'<',''),'>',''),'?',''),'/',''),'"','')

  • GrzegorzM Profile Picture
    18 on 20 Nov 2017 at 13:02:26
    Re: is it possible to replace multiple strings in one replace function?

    Thanks Peter for initial solution, and thanks Simon for your printscreens. I managed to figure this out also for my flow.

     

    For anyone who is interested, here are the 2 formulas you need:

    • createArray('&','_',',','.',';',':','/','"','"','!','@','$','%','^','+','=','\','|','<','>','{','}')
    • replace(Variables('textfeed'),item(),'')

    And also the printscreens of my solution.

    2017-11-20 13_54_52-Edit your flow _ Microsoft Flow 1.png

     

    2017-11-20 13_56_01-Edit your flow _ Microsoft Flow 2.png

     

     

  • GrzegorzM Profile Picture
    18 on 20 Nov 2017 at 12:27:14
    Re: is it possible to replace multiple strings in one replace function?

    Simon, could you please post the formula you have in replace(...) ? If I understand well, I need to refer to replace text in the 'textfeed' variable, but not really sure how to refer to content of this variable?

  • SimonH Profile Picture
    8 on 20 Nov 2017 at 11:35:07
    Re: is it possible to replace multiple strings in one replace function?

    thanks peter,

     

    As I don't use Dynamics I ended up using a Variable action instead. Initialise a varibale outside the for each and setting it to the initial value target output converted to text in this cse), then in the loop, set the variable with the upated value.

    Capture.PNG

     

    this works great if you want to replace the text with the same value (or in this case remove it) but I'm wondering if instead of an array you could use a json, where you find the 'key' then update it with the value.

  • Community Power Platform Member Profile Picture
    on 20 Nov 2017 at 07:24:48
    Re: is it possible to replace multiple strings in one replace function?

    Here they are

    extended conditions.PNGnog meer.PNG

     

  • GrzegorzM Profile Picture
    18 on 20 Nov 2017 at 07:16:19
    Re: is it possible to replace multiple strings in one replace function?

    I get the idea, but it would help a lot if you could post the printscreen with expanded loops sections - the formulas are key here 🙂

     

    Thanks a million!

  • SimonH Profile Picture
    8 on 17 Nov 2017 at 00:31:16
    Re: is it possible to replace multiple strings in one replace function?

    could post a screenshot of your expanded condition?

    But if Iunderstand you correctly, in your condition you are writing back to dynamics, so when the loop starts again it works with the updated variable?

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Automate - Building Flows

#1
stampcoin Profile Picture

stampcoin 103

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 82 Super User 2025 Season 1

#3
David_MA Profile Picture

David_MA 60 Super User 2025 Season 1

Overall leaderboard
Loading started
Loading started