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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Automate
Unanswered

Replace string

(0) ShareShare
ReportReport
Posted on by 391

Hi, can someone please show me how can I remove the string Dynamic from "Initialize variable" and replace it with the value of "Initialize variable 2" ?

 

On a side note, the string “Dynamic” can be changed from time to time to another random string 

 

 

So the end result should be "Static Hola Static2".

 

 

nicklim_0-1697706676961.png

 

Categories:
I have the same question (0)
  • Chriddle Profile Picture
    8,436 Super User 2025 Season 2 on at

    Use following Expression:

    replace(variables('DynamicString'), 'Dynamic', variables('ReplacementString'))

     https://learn.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#replace

     

  • nicklim Profile Picture
    391 on at

    @Chriddle 

     

    Sorry I should’ve be more clear. The string “Dynamic” can be changed each time. For example Dynamic123 or maybe Dynamic456.

     

    im trying to get power automate to replace the string between Static and Stanic1 with variables(‘ReplacementString’)

  • Srini007 Profile Picture
    3,327 Super User 2025 Season 2 on at

    Hi @nicklim 

     

    Try as below

     

    Srini84_0-1697710291687.pngSrini84_1-1697710313860.png

     

    So, in compose it will be as below

    replace(variables('OrignalString'), variables('StringToReplace'), variables('ReplacementString'))

     Replace will require 3 parameters

    1) MainText 2)OldText 3) New Text

     

    You can refer also below for your reference

     

    https://manueltgomes.com/reference/powerautomate-function-reference/replace-function/

     

     

    If you find this reply helpful, please consider giving it a LIKE AND

    If this reply answers your question or solves your issue, please ACCEPT AS SOLUTION

     

    Thanks,

    Srini

     

     

  • Chriddle Profile Picture
    8,436 Super User 2025 Season 2 on at

    You have to think of a proper definition of  'Static' and 'Static1' (or 'Dynamic') 😉

    How can you distinguish static and dynamic parts of the string?

  • nicklim Profile Picture
    391 on at

    @Chriddle 

     

    As an example

     

    When an email arrives into my mailbox.

     

    The email body contains a sentence.

    Product: Apple x1

     

    'Product:' and 'x1' will always be the same string when the email arrives whereas the string between those two can be changed to maybe Product: Orange x1

     

    I hope that make sense.

     

    Thanks

     

  • nicklim Profile Picture
    391 on at

    Hi @Srini007 

     

    Sorry for the confusion, the string “Dynamic” can be changed from time to time.

     

    As an example

     

    When an email arrives into my mailbox.

     

    The email body contains a sentence.

    Product: Apple x1

     

    'Product:' and 'x1' will always be the same string when the email arrives whereas the string between those two can be changed to maybe Product: Orange x1

    hope that makes sense.

     

    thank you 

     

  • Verified answer
    Srini007 Profile Picture
    3,327 Super User 2025 Season 2 on at

    Hi @nicklim 

     

    I believe this is what you are looking for

     

    Srini84_0-1697713216193.png

    Srini84_1-1697713242995.png

     

    The flow remains same, but StringToReplace variable you need to write an expression it will split and get the Dynamic value Orange or Apple etc which is in between Product: and  x1, Below is the expression

     

    first(split(last(split(variables('OrignalString'), 'Product: ')), ' x1'))

     

    and follows by the end expression of the compose to see the replaced value

     

    replace(variables('OrignalString'), variables('StringToReplace'), variables('ReplacementString'))

     

    Srini84_2-1697713457631.png

    Srini84_3-1697713464659.png

    Above is the end flow

     

    If you find this reply helpful, please consider giving it a LIKE AND

    If this reply answers your question or solves your issue, please ACCEPT AS SOLUTION

     

    Thanks,

    Srini

     

  • Verified answer
    Chriddle Profile Picture
    8,436 Super User 2025 Season 2 on at

    Or so:

    Chriddle_0-1697713820853.png

    replace(
    	outputs('OldString'),
    	subString(
    		outputs('OldString'),
    		length('Product: '),
    		sub(lastIndexOf(outputs('OldString'), ' x1'), length('Product: '))
    	),
    	outputs('ReplacementString')
    )

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard