cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
claudia
Helper IV
Helper IV

Variable in Power Automate Desktop

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.

 

 

 

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions

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!

 

View solution in original post

Waylold
Advocate II
Advocate II

@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

 

 

View solution in original post

10 REPLIES 10
MichaelAnnis
Super User
Super User

No...mine is working just fine.

 

Are you splitting text with the underscore?

MichaelAnnis_0-1636559506740.png

 

Hi,

 

yes I am splitting with underscore

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
Microsoft
Microsoft

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

Waylold
Advocate II
Advocate II

@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

 

 

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.

 

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

Waylold
Advocate II
Advocate II

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

 

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. 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

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.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Top Kudoed Authors
Users online (3,720)