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 Characters bef...
Power Automate
Answered

Getting Characters before some characters

(0) ShareShare
ReportReport
Posted on by 1,169

Hello Folks, 
I need help with some compose functions in my flow 

I want to get the characters before 2 characters in my string 

The characters are either _ or Space 

E.g if the String is ABC_ 123_2343 : Extract ABC  and if the String is ABC 123_23426 - extract ABC from this string 

Thanks for every help and suggestions 

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

    Hi @Geeks_D ,

     

    Try below expression:

    if(empty(split(YourString,'_')[0]),split(YourString,' ')[0],split(YourString,'_')[0])

     

    Best regards,

  • Geeks_D Profile Picture
    1,169 on at

    Hi @v-jefferni 

    Thanks for that, 
    The code extract _ for strings starting with _ but extract all the string for Character that start with space 

    E.g - ACB_123  works fine 

    ABC 1233 will extract everything 
    Once again thanks for your help 

  • Verified answer
    v-jefferni Profile Picture
    Microsoft Employee on at

    Hi @Geeks_D ,

     

    I was thinking there could be _and space together within the string. If it would be either _ or space within the string, try below expression:

    split(replace(YourString,' ','_'),'_')[0]

     

    Best regards,

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 286

#2
David_MA Profile Picture

David_MA 256 Super User 2026 Season 1

#3
Expiscornovus Profile Picture

Expiscornovus 225 Most Valuable Professional

Last 30 days Overall leaderboard