Anyone have an idea how I can remove all the text in a file between a specific section/attribute using Power Automate Desktop?
<Section.01>text that I need to remove</Section.01>
@ralphloszak Yes, I can see two actions which you can use if the file is xml, I could not find any other action to remove/extract a specific text from the file
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.
Regex will pull it out.
Unfortunately Ive yet to practice getting the middle of a string, just the start or the end at the moment.
I think Regex is the way to go on this occasion
Behold! Removing text between two text segments:
SET Text TO $'''<Section.01>text that I need to remove</Section.01>''' Text.Replace Text: Text TextToFind: $'''(?<=<Section.01>).+(?=</Section.01>)''' IsRegEx: True IgnoreCase: False ReplaceWith: $'''%''%''' ActivateEscapeSequences: False Result=> Replaced
(copy and paste the code into PAD)
Thanks for the code, just started using Power Automate. Will this code work on any text between the two sections <Section.01>this text changes every day</Section.01>? Can you show me a screenshot of what this would look like in PAD?
As Henrik said, just copy and paste the text into pad and the actions will magically appear.
Yes it will work with any text between the 2 sections.
Go here https://regexr.com/
Put Henriks code in the top text box and the text you want to work on in the bottom, you can then replace the text between the sections with whatever you want and it will still work regardless.
WOW, ok that easy, did not expect that. Got that working. What about if the text between the two sections is multiple sentences with commas, periods, and other special characters? I think I need to change something.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
Read the latest about new experiences and capabilities in the Power Automate product blog.
If you are a small business ISV/Reseller, share your thoughts with our research team.