cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ralphloszak
New Member

Remove/delete text between attribute/section in Power Automate Desktop

Anyone have an idea how I can remove all the text in a file between a specific section/attribute using Power Automate Desktop?

For example:  

<Section.01>text that I need to remove</Section.01>

8 REPLIES 8
jinivthakkar
Dual Super User
Dual Super User

@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

jinivthakkar_0-1642614456314.png

--------------------------------------------------------------------------------

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.

 

UK_Mike
Post Prodigy
Post Prodigy

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

Henrik_M
Dual Super User
Dual Super User

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)

Henrik !!! Where have you been lol.

Ive just spent a half hour messing with capture groups lol.   

Perfect code, I checked it for you 😄

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.

Go to the web link I provided and try it out yourself, replace the inner text with whatever may come up in the future...

Helpful resources

Announcements
MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

New Process Advisor Capabilities carousel.png

Read the blog for the latest news

Read the latest about new experiences and capabilities in the Power Automate product blog.

PA Survey Carousel Image.png

We want to hear from you!

If you are a small business ISV/Reseller, share your thoughts with our research team.

Users online (3,109)