Skip to main content
Question

How do I replace several unaccepted characters with Formatter

  • July 13, 2023
  • 2 replies
  • 617 views

dshaines

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

Troy Tessalone
Zapier Orchestrator & Solution Partner
Forum|alt.badge.img+14
  • Zapier Orchestrator & Solution Partner
  • July 13, 2023

Hi @dshaines 

Good question.

Some options:

  1. Ask AI
    1. ChatGPT
    2. OpenAI
  2. Code
    1. JavaScript
      1. Help for .replace() method
    2. Python

shalgrim
Forum|alt.badge.img+8
  • Zapier Staff
  • July 14, 2023

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