web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

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,553 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
    12,982 Super User 2025 Season 2 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 519 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 296 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard