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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Find phrase in a text ...
Power Automate
Unanswered

Find phrase in a text file, then perform an action if that text is found

(0) ShareShare
ReportReport
Posted on by 8

Hello all, 

 

Very new to Power Automate, and am attempting to create a flow that will work with a daily text document release.

I can get that file and save it to sharepoint, but I wish to scan the file afterwards for a specific line of text, and then do an action for every line of text after that line until the automation sees a line break. 

 

Example: I want to look for 'Material lists", and if it finds that phrase, it will create a To Do task for each subsequent line of text ("Bill of material 1", "Auxiliary Material 4", etc) until a line break is found in order.

 

How would I go about doing this?

 

Thanks!

Categories:
I have the same question (0)
  • Rhiassuring Profile Picture
    8,692 Moderator on at

    What format are the documents? Word? Or Excel sheets? Or .txt? 

     

    Depending - if you can extract the text from the file - you can do this with Find Text / Substring and a variable set with a New Line. Let me know about the format, maybe post an anonymized example of the output, and we'll figure it out.

     

     

  • CDowlin Profile Picture
    8 on at

    The export from the email is currently a .txt document. Each daily release follows a certain structure, and this would be an example:

     

    Material Lists
    Project1-BOM.xls
    Project2-ANCILLARY_HW.xls

     

    Revisions
    Project3-Piece1REV02.dxf
    Project3-Piece6REV01.dxf
    Project4-Piece14REV01.dxf
    Project1-Piece11REV03.dxf
    Project3-Piece11REV05.dxf

     

    Remedials
    Project3-remedial001-issue.pdf
    project3-remedial002-issue.pdf
    project5-remedial011-issue.pdf

     

    Each group of items has a line of 'header' text, followed by the names of the files generated on that day, and each group is separated by a line break. Not every section appears on every release, and the number of items in each group can vary. 

     

    I'm using .txt with sharepoint currently because it seems to segregate everything into lines as they appear in the attachment, but can convert to another document type for greater utility if necessary.

     

    Thanks for the help!

     

  • AndreasN Profile Picture
    318 Super User 2024 Season 1 on at

    I tried recreating the flow with a split function, but I am having issues with the formatting of the TXT.

    The delimiter to split each string, would be ENTER, so I've initialized a variable and simply just pressed ENTER and then use that string variable to define the delimiter in the split compose. 

    Doing so gives me a weird result, but you might be able to do a successful apply to each on this.

    AndreasN_2-1699367420759.png

     

    AndreasN_3-1699367541072.png

     

     

    Honestly, I would suggest saving the TXT as a PDF, use the already trained OCR AI in the AI builder which extracts text in PDF documents. You can simply customize the template they have already created, this will create an apply to each for all strings in the document, and then you can create a SWITCH or a CONDITION to apply the logic you need for each string.

  • CDowlin Profile Picture
    8 on at

    Would there be a way to export it in a similar fashion to an excel spreadsheet? I may be able to utilize the data for more than just this particular automation , if so.

  • Matthy79 Profile Picture
    4,188 Super User 2024 Season 1 on at

    Hello @CDowlin 

     

    Try this:

     

    skip(split(split(split(YOURFILECONTENT'Material Lists')?[1], decodeUriComponent('%0D%0A%0D%0A'))?[0], decodeUriComponent('%0D%0A')), 1)
     
    Instead of "YOURFILECONTENT" you have to put in the Text you want to search.
  • CDowlin Profile Picture
    8 on at

    Can you break down what this line of code is doing? apologies, am still very unfamiliar.

  • Matthy79 Profile Picture
    4,188 Super User 2024 Season 1 on at

    split separates a string by using another string. I used decodeUriComponent to split by crlf (‘%0D%0A’ is the Uri decoded string for that). The rest is just picking the right values of the array created by split.

     

    You have to read it from the inside out.

     

    1.) Split by ’Material Lists’ and take the string after (If ‘Material Lists’ would be inside the whole string more often, then only the string from the first to the second would be recognized).

    2.) Split the string from first step by 2 crlf and take everything before.

    3.) Split the string from 2. Step by crlf and take everything except the first line which would be empty (You could change that if you use ‘Material Lists’ + crlf to split in step 1).

  • CDowlin Profile Picture
    8 on at

    Apologies for the radio silence... had a thought. would it be easier to load these into an excel spreadsheet , and then have them sorted to make the tasks? 

    and i also apologize for having a hell of a time trying to decipher the code here... i'm not making the connection in my head.

  • Matthy79 Profile Picture
    4,188 Super User 2024 Season 1 on at

    Hello @CDowlin 

     

    This wouldn’t be easier. I also would try to avoid excel whenever possible.

     

    Have you tried the formula. Doesn’t it work? Did you receive an error. Send a screenshot of where you have the problem.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 589

#2
Valantis Profile Picture

Valantis 328

#3
David_MA Profile Picture

David_MA 284 Super User 2026 Season 1

Last 30 days Overall leaderboard