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 / Matching text in a fil...
Power Automate
Suggested Answer

Matching text in a file name

(0) ShareShare
ReportReport
Posted on by 43
I'm trying to match the C8729 stored in Matches2 to the CurrentItem of File2 but I'm not getting a match. Can someone tell me what I need to change. I pasted the Thanks
 
 
I have the same question (0)
  • Suggested answer
    eetuRobo Profile Picture
    4,579 Super User 2026 Season 2 on at
    Your Matches2 variable is a list variable. You need to check if CurrentItem contains an item from the list. Now you would need to check Matches2[0] to check the first item.
     
    If you know that you always get just one match then change the Parse text to get first occurrence only


    That way it produces "Match" variable that is text type rather than a list type.

    If there can be more matches then you need to loop the Matches2 list and have the condition inside that loop. You can do it with for each or with loop index
  • Suggested answer
    VishnuReddy1997 Profile Picture
    2,666 Super User 2026 Season 1 on at
    Hey Hi,
     
    Please find the solution below as shown in image.
     
     
    Code:
    Folder.GetFiles Folder: $'''C:\\Users\\OneDrive\\Desktop\\Power Automate Desktop\\Practice\\PDF''' FileFilter: $'''*''' IncludeSubfolders: False FailOnAccessDenied: True SortBy1: Folder.SortBy.NoSort SortDescending1: False SortBy2: Folder.SortBy.NoSort SortDescending2: False SortBy3: Folder.SortBy.NoSort SortDescending3: False Files=> Files2
    LOOP FOREACH CurrentItem IN Files2
        Text.ParseText.RegexParse Text: CurrentItem.NameWithoutExtension TextToFind: $'''s*C\\d{4}''' StartingPosition: 0 IgnoreCase: False OccurrencePositions=> Positions2 Matches=> Matches2
        IF Contains(CurrentItem.NameWithoutExtension, Matches2[0], True) THEN
            Display.ShowMessageDialog.ShowMessage Message: $'''yes''' Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False ButtonPressed=> ButtonPressed15
        END
    END
    
     
    (Note:- if you got your solution you can mark as solution and gives kudos)
     
    Thanks & Regards
    Vishnu Reddy
  • ME-14102049-0 Profile Picture
    43 on at
    Vishnu,
    Thank you very much for your help and taking the time to answer my post. This seems to be the solution and my flow is working. Just one question what does the [0] in Matches2[0] indicate?
  • Suggested answer
    eetuRobo Profile Picture
    4,579 Super User 2026 Season 2 on at
    Just one question what does the [0] in Matches2[0] indicate?
    That means the first item in the list. 

    So if you have more items in that list then second item would be Matches2[1] and third would be Matches2[2] (lists start from 0 index so first item is 0 index)

     
    I suggest you don't use a list but just take the first occurrence since the name most likely doesn't have more occurrences of C and 4 digits. That way the solution is cleaner. No reason to produce a list that has one text value in it when you can just produce a text variable.
  • VishnuReddy1997 Profile Picture
    2,666 Super User 2026 Season 1 on at
    Hey Hi,
     
    As answered by Eeturobo as you have enabled all the occurance button in Parse text action it will get all matches that will be stored in List form.
     
    So that is reason we are taking only the first occurance that is [0].
     
     
    Regards,
    Vishnu Reddy

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 298 Super User 2026 Season 2

#2
11manish Profile Picture

11manish 150 Super User 2026 Season 2

#3
trice602 Profile Picture

trice602 147 Super User 2026 Season 2

Last 30 days Overall leaderboard