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 function not dele...
Power Automate
Answered

Trim function not deleting whitespace

(1) ShareShare
ReportReport
Posted on by 17

I'm trying to delete whitespace in a string using this expression

 

replace(Trim(triggerOutputs()?['body/Title']),' ','.')

 

This is for a SharePoint triggered flow and the title was renamed to "Full legal name" in the associated list. It trims the ends just fine. But according to this article (https://learn.microsoft.com/en-us/power-platform/power-fx/reference/function-trim), trim should eliminate the extra spaces in the string (it even shows it in one of their examples) as opposed to TrimEnds. And yes, once the string is trimmed, I need to replace the space with a period. I'm using this to generate what their email address will be for later on in the flow. 

 

Currently, if their name comes in as "Desaad  Joker   ", it will trim off the whitespace at the ends and replace the two spaces in the string with periods "Desaad..Joker". What am I missing?

Categories:
I have the same question (0)
  • Verified answer
    DaveMelton Profile Picture
    17 on at

    I think I just answered my own question. The whitespace trim only works that way in Power Apps. Not Power Automate. 

     

    Hey, Microsoft! Can we get some consistency here?

     

    For the rest of you, is there a standard way of removing whitespace? (and yes, I still need a single space between words)

  • Joseff Profile Picture
    37 on at
    Hey David,

    I usually go for something like
     
    trim(replace(replace(replace(triggerBody()?['text'],' ',' _  '),'   _',''),'_  ',''))

    Where triggerBody()?[
    'text'] is the text I want to remove extra spaces from
  • AnthonyAmador Profile Picture
    2,557 Moderator on at
    Hi @DavidMelton

    Unfortunately the trim function doesn't remove the white spaces between words, from documentation the Trim function removes all spaces from a string of text except for single spaces between words.

    What I do to remove the whitespaces is the function replace(), replace ' Hello World ! ' with your variable. 

    replace(' Hello World ! ', ' ', '')
     
    Hope this helps. 
    Anthony. 
  • Suggested answer
    David_MA Profile Picture
    14,586 Super User 2026 Season 1 on at
    -----

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 785

#2
Valantis Profile Picture

Valantis 669

#3
Haque Profile Picture

Haque 563

Last 30 days Overall leaderboard