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 Automate
Answered

Split string

(0) ShareShare
ReportReport
Posted on by 497

Greetings,

 

I have a need to split the following string from this:

1234_5678.901.A_1.jpg

to this:

1234_5678.901.A

If I use the following split function, it splits at the first '_', where I need it to split at the 2nd '_'

split(outputs('Get_File_Name'), '_')[0]

Is there a way to reference the second underscore in the split function?

Thank you; in advance!

 

Update - I resolved this by removing the second '_' in the generated filename and replacing it with a '-'.  I then used the following split function:

split(outputs('Get_File_Name'), '-')[0]

This works for my needs.

Categories:
I have the same question (0)
  • Verified answer
    v-yuazh-msft Profile Picture
    Microsoft Employee on at

    Hi @tianaranjo,

     

    You could also take a try with expression to achieve your needs and don't need to replace '_' with '-':

    split(outputs('Get_File_Name'), '_1.')[0]

     

    Best regards,

    Alice

  • GabrielStJohn Profile Picture
    Microsoft Employee on at

    Hello,  @tianaranjo!

    Have you had an opportunity to apply @v-yuazh-msft‘s recommendation to adapt your Flow? If yes, and you find that solution to be satisfactory, please go ahead and click “Accept as Solution” so that this thread will be marked for other users to easily identify!


    Thank you for being an active member of the Flow Community!

    -Gabriel
    Flow Community Manager

  • StephenM Profile Picture
    55 on at

    i dont quite understand what the [0] does on the expression - could someone please explain

     

    split(outputs('Get_File_Name'), '_1.')[0]

     thanks

    Stephen

  • StephenM Profile Picture
    55 on at

    Also, how did youremove the second '_' in the generated filename and replace it with a '-' ? could you explain that please

     

    many thanks

    Stephen

  • tianaranjo Profile Picture
    497 on at

    @StephenM I'm not an expert so bear with me and if I get this incorrect, hopefully the others on this chain will correct me.  The '0' is referring to an index or location in the string.  Hopefully these links will help:

    https://www.w3schools.com/jsref/jsref_split.asp

    Optional. An integer that specifies the number of splits, items after the split limit will not be included in the array

     

    https://www.digitalocean.com/community/tutorials/how-to-index-split-and-manipulate-strings-in-javascript

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split

     

     

     

  • tianaranjo Profile Picture
    497 on at

    @StephenM - within PowerApps, I was using Concatenate to join the fields with  the '_'.  I simply changed that to '-'.

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
David_MA Profile Picture

David_MA 112 Super User 2026 Season 1

#2
Haque Profile Picture

Haque 52

#3
Ellis Karim Profile Picture

Ellis Karim 51 Super User 2026 Season 1

Last 30 days Overall leaderboard