Remove Characters From String In Power Automate [with Examples]

When we create flows in Power Automate, it’s common to receive text that isn’t perfectly formatted, with extra spaces, unwanted characters, or parts of a string you don’t need. Cleaning the text before saving it to SharePoint, sending an email, or creating a file is essential.

In this tutorial, I will tell you how to remove characters from a string in Power Automate. Here I will cover:

  • Power Automate trim characters from a string to remove unwanted spaces or tabs.
  • Remove Characters with the Replace Function in Power Automate.
  • Strip out unwanted symbols with Power Automate and remove special characters.
  • Remove the first character in a string using Power Automate substring expressions.
  • Power Automate removes the last character for precise text formatting.
  • Remove the first and last characters together with a smart Power Automate substring trick.
  • Cut off extra text using Power Automate, remove the last N characters.
  • Remove multiple characters from a string in Power Automate.

Power Automate Trim Character From String

Before we dig deeper into the remove functions of Power Automate, let’s learn another important and mainly used trim function, how to trim characters from a string in Power Automate.

trim() function of Power Automate returns the string value without the leading and trailing whitespace.

Suppose you are collecting attendee details through a Microsoft Form named Event Registrations.

Power Automate trim function to remove leading and trailing spaces from string

Some people accidentally add extra spaces before or after their names, for example:

" Jon Patel "

Before saving these names into a SharePoint list, you need to clean them up so that they show “Jon Patel” without extra spaces.

Follow the steps below to Trim Characters in Power Automate:

  1. Go to Power Automate. Click on Create Automated cloud flow. Name: Trim Character From String. Select trigger: When a new response is submitted. Select your Microsoft Form from the dropdown.
How to trim characters from text using Power Automate
  1. To retrieve the response, add the Get response details action from the Microsoft Forms connector. Then, select the Form ID from the dropdown menu and choose the Response ID from the dynamic content of the ‘When a new response is submitted’ trigger.
Power Automate expression to trim white space in a variable
  1. Add a compose action and provide the following expression:
trim(outputs('Get_response_details')?['Name'])
Power Automate example to trim tabs and line breaks from string
  1. Add a Create item action for your SharePoint list (or wherever you store registrations). In the Attendee Name column, insert the above compose action output.
Trim specific character from start and end of text in Power Automate

Save the flow and submit a new Event Registration with leading and trailing spaces in the name.

Power Automate compose action with trim() function

After the flow runs successfully, check the SharePoint list: the saved name will appear clean, with no extra spaces.

Power Automate Trim Character From String

This ensures that every attendee name from the Event Registrations form is automatically cleaned up before it’s saved or used elsewhere in Power Automate.

Remove Multiple Characters From a String in Power Automate

You receive daily sales data in a string like Order#1234-Completed, but for reporting, you only need the order number. You can use Power Automate’s Replace function to remove the text Order# and -Completed, leaving only 1234.

To do this, follow the steps below:

  1. Go to Power Automate and click Create -> Instant Cloud Flow. Select Manually trigger a flow as the trigger.
  2. Next, add an Initialize Variable action and provide the parameters below:
    • Name: varData
    • Type: String
    • Value:
Order#1234-Completed
Power Automate replace function example to remove unwanted characters from string
  1. Add a Compose Action to Remove Prefix using the following expression:
replace(variables('varData'),'Order#','')
Replace function in Power Automate to remove punctuation in a SharePoint list item
  1. Add another Compose action (or extend the previous one) to remove -Completed:
replace(outputs('Compose'),'-Completed','')
Power Automate expression for replacing characters with blank value

Click Save, then Test -> Manually -> Run flow. Check the last Compose action’s output. It should display:

Remove multiple characters in a variable with Power Automate replace

Tip: If you need to remove multiple different substrings at once, you can nest replace() functions:

replace(
   replace(variables('varOrder'),'Order#',''),
   '-Completed',''
)

Remove Special Characters From a String In Power Automate

You receive customer feedback through an email form, and some comments include special characters such as @, #, $, or %.

Before saving these comments to a SharePoint list, you want to remove all special characters and keep only letters, numbers, and spaces.

Follow the steps below:

  1. Go to Power Automate -> Click Create -> Instant cloud flow -> choose Manually trigger a flow -> Create.
  2. In the trigger, click + Add an input -> select Text. Name it Feedback.
Power Automate replace() to strip out numbers from a string
  1. Add a Compose Action with a Replace Expression in Inputs, enter the following expression:
replace(replace(replace(replace(replace(replace(replace(replace(replace(
   triggerBody()?['text'],'!',''),'@',''),'#',''),'$',''),'%',''),'^',''),
   '&',''),'*',''),'(','')
Replace certain letters with empty string in Microsoft Power Automate

Click Save -> Test -> Manually. Enter a sample comment, for example:

power Automate tutorial on deleting specific text from dynamic content

Run the flow and check the output of the Compose action.

Remove Special Characters From a String In Power Automate

For common cases, you can chain multiple replace() functions to remove only specific unwanted characters.

Remove the first character in a string using Power Automate substring expressions

Your company generates Order IDs in the format #12345, where the first character (#) is reserved for internal systems. Before sending the Order ID to a customer’s email, you need to remove the # and keep just 12345.

  1. Go to Power Automate -> Click Create -> Instant cloud flow -> choose Manually trigger a flow -> Create.
  2. In the trigger, click + Add an input -> select Text. Name it OrderID.
  3. Add a Compose action in the Inputs box of the Compose action, enter:
substring(triggerBody()?['text'], 1, sub(length(triggerBody()?['text']),1))

Where:

  • triggerBody()?[‘text’]: the original string from the manual input.
  • 1: start at index 1 (second character, because indexes start at 0).
  • sub(length(…),1): take the length of the string minus 1 character.
Remove commas and periods from data using Power Automate replace function

Click Save -> Test -> Manually. Enter a sample Order ID such as #12345.

Replace newline and tab characters using Power Automate

After the flow runs successfully, check the output of the Compose action.

Remove emojis from text using replace() in Power Automate

Power Automate Remove the Last Character From String

In this section, we will learn how to remove the last character from a string using Power Automate.

Suppose you receive customer codes from an external system in the format ABC123-, where the trailing dash (-) is unnecessary. Before saving these codes to a SharePoint list, you need to remove the last character.

  1. Create an Instant cloud flow -> choose Manually trigger a flow.
  2. Add an Initialize variable action and provide the following parameters to store that customer code:
    • Name: varCode
    • Type: String
    • Value: ABC123-
Replace function to remove duplicate spaces in Power Automate
  1. Add a compose action and provide the following expression:
substring(variables('varCode'), 0, sub(length(variables('varCode')),1))
Microsoft 365 Power Automate remove extra symbols

Output:

Power Automate expression to remove last character from a string variable

Remove the First and Last Characters Together From String In Power Automate

Suppose your marketing team receives social media hashtags, such as *Launch2025*, from a third-party app. Before posting these as clean titles in a Teams message, you need to strip the leading and trailing asterisks, leaving only Launch2025.

Follow the steps below:

  1. Create an Instant cloud flow -> choose Manually trigger a flow.
  2. Add an Initialize variable action and provide the following parameters to store that customer code:
    • Name: varTag
    • Type: String
    • Value: *Launch2025*
  3. Add a compose action and provide the following expression:
substring(triggerBody()?['text'],1,sub(length(triggerBody()?['text']),2))

This starts from index 1 (skips the first character) and takes the total length minus 2 (skips thelast character).

How to trim final character in Microsoft Power Automate flow

Save the flow, run a manual test.

Remove trailing character from SharePoint list text using Power Automate

Remove the Last N Characters in Power Automate

Suppose your HR team stores employee ID codes in a SharePoint list in the format EMP45212025, where the last four digits represent the year.

Before generating a report, you need to remove the last 4 characters so the output shows only the core employee code EMP4521.

To do this follow the below steps:

  1. Create an Instant cloud flow -> choose Manually trigger a flow.
  2. In the trigger, click + Add an input -> Text. Name it EmployeeID.
  3. Add a compose action and provide the following expression:
Power Automate expression to remove last N characters from a string

Save the flow, run a manual test, and enter a value such as EMP45212025.

Remove trailing characters from SharePoint list field in Power Automate

Click Run Flow. Once the flow runs successfully, click on the Compose action to check the output.

Power Automate substring example to delete last N letters

In this Power Autoamte tutorial, we explored many methods to remove or trim characters from strings:

  • Trim: remove leading and trailing spaces.
  • Replace: delete specific words, symbols, or substrings.
  • Substring: precisely cut the first, last, or last N characters.
  • Nested Replace: strip multiple different characters in a single expression.

By combining these functions, we can handle everything from simple whitespace cleanup to complex text-formatting needs in Power Automate.

You may also like the following tutorials:

Power Apps functions free pdf

30 Power Apps Functions

This free guide walks you through the 30 most-used Power Apps functions with real business examples, exact syntax, and results you can see.

Download User registration canvas app

DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

Download a fully functional Power Apps Canvas App (with Power Automate): User Registration App