Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
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?

  • Suggested answer
    David_MA Profile Picture
    11,517 Super User 2025 Season 1 on at
    Trim function not deleting whitespace
    -----
  • AnthonyAmador Profile Picture
    2,553 Super User 2025 Season 1 on at
    Trim function not deleting whitespace
    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. 
  • Joseff Profile Picture
    37 on at
    Trim function not deleting whitespace
    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
  • Verified answer
    DaveMelton Profile Picture
    17 on at
    Re: Trim function not deleting whitespace

    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)

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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 566 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 516 Super User 2025 Season 1

#3
stampcoin Profile Picture

stampcoin 492