Skip to main content

Notifications

Community site session details

Community site session details

Session Id : aF+HVj4BLOP+maCg9+foDb
Power Apps - Building Power Apps
Answered

Last space in string

Like (0) ShareShare
ReportReport
Posted on 25 Feb 2023 12:14:58 by 182

Hi Guys,

 

Trying to figure out how to get the last space within a string and then extract all characters after the last space.

 

This is a dynamic string and not in all instances will the string have a space. I only need to extract all characters after the last space if there is a space.

 

Any help is greatly appreciated.

 

Thanks

  • Pstork1 Profile Picture
    66,154 Most Valuable Professional on 25 Feb 2023 at 13:35:56
    Re: Last space in string

    I hadn't noticed that @CNT already answered this.

  • Pstork1 Profile Picture
    66,154 Most Valuable Professional on 25 Feb 2023 at 13:34:32
    Re: Last space in string

    I think the easiest way to do what you are asking is to use a combination of Split and Last functions.

    Last(Split(<<string to extract from>>,' '))

    Split will split the string into an array based on the spaces in the string. Then Last will give you whatever follows the last space.

  • Verified answer
    CNT Profile Picture
    10,919 Super User 2025 Season 1 on 25 Feb 2023 at 12:59:23
    Re: Last space in string

    @christian12 

    This will return a Blank as there are no spaces,

     

    With({myString:"Apples,Oranges,Bananas"},
     If(IsMatch(myString, Space, Contains), Last(TrimEnds(Split(myString, " "))).Result, Blank())
    )

     

    This will return đźŤŚđźŤŚđźŤŚ

     

    With({myString:"Apples,Oranges, Bananas"},
     If(IsMatch(myString, Space, Contains), Last(TrimEnds(Split(myString, " "))).Result, Blank())
    )

     

     

    Please remember to give a 👍 and accept my solution as it will help others in the future.

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Building Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 89 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 54

#3
Michael E. Gernaey Profile Picture

Michael E. Gernaey 42 Super User 2025 Season 1

Overall leaderboard