web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Extract first few characters of a string

(0) ShareShare
ReportReport
Posted on by 257

I have a field for which I want to extract the first few characters of a string which are always followed by an underscore character (_).  The length of the string is variable but what I'm interested in extracting is what precedes the underscore. 

 

for example, my string could be: 

 

xyz_Company1

 

or it could be 

 

QRS STUVWXYZ_Company2 

 

how can I extract for these examples only xyz and QRS STUVWXYZ

 

 

thank you for your help!

 

I have the same question (0)
  • Verified answer
    Paulie78 Profile Picture
    8,418 Moderator on at
    Re: Extract first few characters of a string

    Like this:

     

    PowerAutomateSearchString.PNG

    The expression in the compose action is:

     

    substring(variables('stringToSearch'),0,indexOf(variables('stringToSearch'), '_'))

     

    And the output of the compose step is what you are after:

     

    PowerAutomateSearchStringResult.PNG

  • F_Quint Profile Picture
    257 on at
    Re: Extract first few characters of a string

    @Paulie78  thank you so much. That's exactly what I was after!

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 659 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 386 Moderator

#3
chiaraalina Profile Picture

chiaraalina 290

Last 30 days Overall leaderboard