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 Platform Community / Forums / Power Automate / Extract first few char...
Power Automate
Unanswered

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!

 

Categories:
I have the same question (0)
  • Verified answer
    Paulie78 Profile Picture
    8,422 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 462 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 456 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard