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 / Variable in Power Auto...
Power Automate
Answered

Variable in Power Automate Desktop

(0) ShareShare
ReportReport
Posted on by 208

Hello everyone,

 

I have a folder with 3 files. The files have the same naming convention: nnnnnn-E1_Product name_LBL

I need to extract from the file name the Product name

I have split a text as below:

 

claudia_0-1636550680225.png

If I want to set a variable, I receive an error " Index '1' is out of range

claudia_1-1636550785383.png

 

Does anybody knows what is wrong? 

 

Thank you for your kind support.

 

 

 

 

 

I have the same question (0)
  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    No...mine is working just fine.

     

    Are you splitting text with the underscore?

    MichaelAnnis_0-1636559506740.png

     

  • claudia Profile Picture
    208 on at

    Hi,

     

    yes I am splitting with underscore

  • Verified answer
    MichaelAnnis Profile Picture
    5,727 Moderator on at

    It's so weird.  Mine is working just fine with [1].  This is weird, but have you tried deleting the command and redoing it.  Also, show me your total flow screen.  I want to make sure it's reading it correctly.

    MichaelAnnis_0-1636559887561.png

    I'm heading into a meeting, so you won't hear from me for about an hour.  Good luck!

     

  • JamesP_MSFT Profile Picture
    Microsoft Employee on at

    @claudia from what you are showing, the index number you are using is within limits. 
    Could you paste a screenshot of your flow?

  • Verified answer
    Waylold Profile Picture
    106 on at

    @claudia 

     

    Have you tried simply extracting with RegEx? It would save time with steps. 

    Waylold_0-1636723896032.png

    Waylold_1-1636723928956.png

     

    Copy and paste the below into the flow builder window and replace the text to parse with the file name variable. 

     

    Text.RegexParseForFirstOccurrence Text: Filename TextToFind: $'''(?<=_)(.*?(?=_))''' StartingPosition: 0 IgnoreCase: True Match=> varProductName

     

     

  • claudia Profile Picture
    208 on at

    Hi Michael,

     

    I have checked the flow one more time and I saw that, the order of the actions was wrong 😬. I have made the correction and now is working.

     

    Thank you for taking time to answer.

     

  • claudia Profile Picture
    208 on at

    Hi,

     

    RegEx is something very new and very interesting for me. I know it can be used, but it is not so easy for me to handle it. Please, beside the Microsoft documentation, do you know some sources from where a beginner like me could learn some things?

     

    Please can you explain this expression: 

    (.*?(?=_))

     

    Thank you

    Claudia

  • Highboy Profile Picture
    1,187 Super User 2024 Season 1 on at

    Highboy_0-1636979461273.png

    https://regexr.com/

  • Waylold Profile Picture
    106 on at

    @claudia, It looks like @Highboy and I share the same site. Great site for building/testing on the fly with real world data. 

     

  • Waylold Profile Picture
    106 on at

    The totality of the expression is doing a few things: 

    (?<=_)(.*?(?=_))
    1. We are looking for an occurrence of underscore, the using the positive lookbehind function both using it as the start point and leaving out of the result. 
    2. We then use a capture group to consolidate functions. We need to instruct the computer to continue looking until the next function. (.*) represents that. 
    3. ?(?=_) We're looking for the next occurrence the underscore and finding everything in between to the last argument as a string.

    Hope that helps. 

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 June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 267 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 196

#3
Haque Profile Picture

Haque 182

Last 30 days Overall leaderboard