Question

How do I replace several unaccepted characters with Formatter

  • 13 July 2023
  • 2 replies
  • 155 views

Userlevel 1

Hello. As the title states I am looking for a way to replace multiple characters that may be found within the “Input text” field of Formatter/Replace. The reason for this is we are attempting to pass along a new Teams channel name to Microsoft Graph and there are known characters that don’t play nice.

~#%&*{}+/\:<>?|‘”

I am able to test with only one of these characters in the “Find” field and achieve removing that characters, but how do I include several(all of them would be ideal) from a single step?

Many thanks for any assistance.


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

2 replies

Userlevel 7
Badge +14

Hi @dshaines 

Good question.

Some options:

  1. Ask AI
    1. ChatGPT
    2. OpenAI
  2. Code
    1. JavaScript
      1. Help for .replace() method
    2. Python
Userlevel 6
Badge +8

Hey @dshaines ,

Here is a Python code step that should work for you:

import re

output = [{'output_string': re.sub(re.compile("[~#%&\*\{\}\+/\\:<>\?\|‘”]+"), ' ', input['input_string'])}]

 

That will work if you have your input set up like so:

 

Does that help? Let me know if you have any more questions