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 / Getting substring out ...
Power Automate
Answered

Getting substring out of a string in PowerAutomate using an expression

(0) ShareShare
ReportReport
Posted on by 68

Hi all,

 

I'm building this Flow that needs to rename a created document before it gets moved to a folder. Couldn't find what I'm looking for in here, so posting a new topic for it. I'm trying to get everything after the second '-' character in a string. For example, out of the string 'BugsBunny-Arn-999999-67378-CLMPDVVD-TB-GN.docx', I'm trying to make it to be only '999999-67378-CLMPDVVD-TB-GN.docx', what is the correct expression that will work? Have in mind that'd be a dynamic value, so I'm basically taking the Name of the file first and then need to convert it to have only what is after the second '-' character. Thank you!

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

    OK Benny Blanco from the Bronx!!

    GetTheValue.PNG

    Expression:

     

    split(outputs('Compose'), '-')[2]

     

    https://www.youtube.com/watch?v=zMA5uCYloDk

     

  • Verified answer
    bibhupanigrahi Profile Picture
    240 on at

    Hi @benny_blanco , you cannot easily find second index of a character in a string, so the substring() function is not helpful here. I used a combination of split() and join() to get the exact part of string in this case.

    1. Split the original string using the expression "split(variables('mystring'),'-')". This creates an array.
    2. Now join the array elements in a a Compose starting the third item in the array using the expression "join(skip(variables('myarray'),2), '-')". This results in the string you want.

    get-substring-with-split-and-join1.jpgget-substring-with-split-and-join2.jpg

    Hope this helps!

  • Paulie78 Profile Picture
    8,422 Moderator on at

    Wow - I read the question completely wrong. 😄

  • Paulie78 Profile Picture
    8,422 Moderator on at

    This is my new version now I have read the question properly:

    join(skip(split(outputs('Compose'), '-'),2),'-')

    BennyBlanco.PNG

  • benny_blanco Profile Picture
    68 on at

    Just tested bibhupanigrahi's suggestion which worked perfectly. Thank you @bibhupanigrahi !

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 67

#2
David_MA Profile Picture

David_MA 64 Super User 2026 Season 1

#3
Expiscornovus Profile Picture

Expiscornovus 39 Most Valuable Professional

Last 30 days Overall leaderboard