• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Tachytelic.net

  • Sco Openserver
    • Sco Unix Support
    • SCO Openserver Installation ISOs
    • SCO Openserver Binaries
    • Add a Hard Drive to an Openserver 5 Virtual Machine
    • Install SCO Vision SQL-Retriever ODBC Driver on Windows 10
    • License Expired on Virtual SCO Openserver Installation
    • How to reset the root password on SCO Openserver 5
  • Scripting
    • PowerShell
      • Add leading zeros
      • Check if a File Exists
      • Grep with Powershell
      • Create Environment Variables
      • Test for open Ports
      • Append to a Text File
    • VBScript
      • Check if a File Exists
      • lpad and rpad functions
      • Windows Update E-Mail Notification
  • Office 365
    • Connect to Office 365 with PowerShell
    • Add or remove an email alias using Powershell
    • Change Primary email address of Active Directory user
    • How to hide an AD user from the Global Address List
    • How to hide mail contacts from the Global Address List
    • Change the primary email address for an account with PowerShell
    • Change Primary email address of an AD User
    • Grant a single user access to access to all calendars
    • Forward email to an external address using Powershell
    • Convert shared mailbox to user mailbox with Powershell
  • Get in Touch
  • About Me
    • Privacy Policy

Remove unwanted characters from a string in Power Automate

October 30, 2020 by Paulie Leave a Comment

This post explains how to remove unwanted characters from a string in a Power Automate flow. These can be regular characters or unprintable special characters, such as control codes that you need to strip out.

The example string:


<note>
	<to>[email protected]</to>
	<from>Michael Knight</from>
	<heading>Reminder</heading>
	<body>Don't forget to clean KITT this weekend!!!
	</body>
</note>

I want to remove the apostrophe, exclamation marks and non-printable characters.

You can see the non-printable characters in Notepad++ :

First of all, let’s take a look at the basic flow structure:

Image of a Power Automate Flow to remove unwanted characters

In the above example I have only put two characters in the array, like this:

[ "\u0027", "!" ]

This requires some explanation, you might be wondering what the first element in the array is!

\u0027 is the Unicode representation of the apostrophe character. The complete array to remove everything I want to clean from this string is:

[ "\u0001", "\u0007", "\u0027", "!" ]

It’s important to know how to remove non-printable characters or control codes, because you cannot type them into the expression editor in Power Automate. So using the Unicode representation makes it possible.

A note of caution, if you load up a big array of unwanted characters like this:

[ "\u0001", "\u0007", "'", "!", "@", "£", "^", "=", ",", "%", "[", "]", ";", "~", "?", "<", ">", "|", "`", "¬", "/" ]

Then the apply to each loop will take longer to execute. So try to keep the number of replacements down to the minimum possible. If you want more speed you can do it all in a single action with a nested replace, but it is more difficult to read.

Hope this helps.

Related

Filed Under: Uncategorized

Reader Interactions

Leave a Reply Cancel reply

Primary Sidebar

Link to my LinkedIn Profile
Go to mobile version