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 / Trim with multiple mat...
Power Automate
Unanswered

Trim with multiple matching values - selecting the first value?

(0) ShareShare
ReportReport
Posted on by 40

Does anyone have experience using trim when multiple values match the trim criteria?

 

Currently it defaults to the last match value and I need to use the first match value

 

For example if my data looks like the below:

 

To: a
From: 1

 

To: b
From: 2

 

To: c
From 3

 

 

 

trim(first(split(last(split(outputs('my_string'),'To:')),'From:')))

 

 

 

The above will return c

 

However I want to return always the first match, which is a

 

The number of results might change, but regardless I would like trim to always use the first match in the string rather than the last.

Categories:
I have the same question (0)
  • Mister_Shaik Profile Picture
    1,008 on at

    Hi @DanNewton ,

     

    Just to clarify, trim is a string expression that removes extra spaces or new lines.

     

    You can get the first match using this expression:

    trim(last(split(first(split(outputs('Compose'),'From:')),'To:')))

     

    ExpressionExpression

     

    You will always get the first match:

     

    OutputOutput

     

    Hope you find this helpful!

     

    Kind Regards,

    Shaik Sha
    ________________________________________________________________________

    If I have answered your question, please mark the post as Solved.
    If you like my response, please give it a Thumbs Up.

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 308 Super User 2026 Season 2

#2
11manish Profile Picture

11manish 171 Super User 2026 Season 2

#3
Haque Profile Picture

Haque 137 Super User 2026 Season 2

Last 30 days Overall leaderboard