Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Last space in string

(0) ShareShare
ReportReport
Posted on by 178

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
    Pstork1 64,741 on at
    Re: Last space in string

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

  • Pstork1 Profile Picture
    Pstork1 64,741 on at
    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
    CNT 10,919 on at
    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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,445

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,741

Leaderboard