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 / Extract first few char...
Power Automate
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!

 

Categories:
  • Verified answer
    Paulie78 Profile Picture
    8,424 Moderator on at

    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

    @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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 289

#2
11manish Profile Picture

11manish 282 Super User 2026 Season 2

#3
Henil Profile Picture

Henil 119

Last 30 days Overall leaderboard