Replace Function

:bullseye: What is your goal?

Hello everyone,
I would like to make it possible for the “replace function” to replace several special characters in a form field (First and Last Name). Sometimes people enter special characters such as (/=:;?) and I would like these characters to be replaced by (-).

Do you think this is possible, and if so, how?
Thank you in advance :wink:

:camera_with_flash: Screenshots: scenario setup, module configuration, errors

1 Like

Yes, this is possible, and there are two main approaches:

• Stack multiple replace() functions. You can chain several replace() functions, one per character:

replace(replace(replace(Nom; /;-);=;-);:;-)

This works, but it quickly becomes verbose and harder to maintain if the list of characters grows.

• Use a Text parser (regex) (recommended): A cleaner and more robust solution is to use a regex pattern to replace all unwanted characters at once.

With the Text parser Replace module, you can use the following pattern:

[^a-zA-ZÀ-ÿ0-9 -]

and “-" as replacement character

This second approach is usually the best choice if you want consistent and “clean” name fields.

2 Likes

Hello, here is a formula that should help you complete this replacement.

replace(Name; "[^a-zA-Z0-9 ]"; "-")

You could also use:

replace(FirstName; "[/=:;?]"; "-")

However the first example is a more robust solution as it will be able to catch any non-standard characters that may occur.

Generally when using the replace() function, it goes like this replace(VariabletoModify, “regex solution”).

so it’s easy to get tripped up when building patterns.

Hope this helps!

1 Like

Welcome to the Make community!

I noticed that you are doing this to create a valid filename. This process is also called “converting text to slug”.

You do not need a separate Text Parser “Replace” module for this - it is good practice to use the built-in functions to avoid spending unnecessary operations.

I have a specific formula containing regular expression patterns just for this:

Screenshot 2026-02-03 085022

{{ lower(replace(replace(text; "/\s*(\w[\W\w]{0,28}\w)\b\s*/"; "$1"); "/\W+/g"; "_")) }}
:high_voltage: Make Input Markup: Copy-paste the above into the field, including start/end curly brackets for it to import as intended :warning:

Explanation

First replace function:

Gets the first 30 characters or less, that begins and ends with any word character \w (equivalent to [a-zA-Z0-9_]). This is because you’ll want to avoid overly long filenames should your input be too long for some reason.
Screenshot 2026-02-03 084232
(selected text is highlighted in green)

Second replace function:

Replaces any non-word character (outside of [a-zA-Z0-9_]) within the selected text with an underscore _ (or you can change it to a hyphen -).

Lower function:

Converts the output to lowercase!

What is a “Pattern”?

When you see the word “Pattern” in Make, it most likely refers to a Regular Expression (pattern).

Regular expressions is something you’ll have to learn and practice to get better at, and you aren’t expected to know how to use it within Make. However, it is a very powerful and useful tool as you can possibly easily reduce lots of operations into a single operation within your scenarios. For example, instead of “looping” through arrays with Iterators and Filters, we can convert it into a single text variable before extracting data in a single operation.

Regex101.com is a very useful tool that you can use to build patterns, as it explains what each part of the regular expression is doing, and shows you live match results. Using R101 allows you to bootstrap your pattern outside of Make so that you can test and validate the pattern before applying it, saving you time and operations.

Quick Guide on How to Use Regex101.com

  • Top: Paste in the regular expression pattern
  • Below: Paste a complete/full example text you are trying to match from
  • Select: “ECMAScript” from the left sidebar

  • Right: Explanation of what the pattern does
  • Bottom Right: Preview of matches from the example text

:clipboard: Note: :light_bulb:
Using regex101 will allow you to verify that the pattern is working correctly, before you use it in Make.

Learning & Using Advanced Regular Expressions

Within Make’s documentation, it isn’t mentioned much, and I could only find a reference here Text parser - Help Center, which says:

The search pattern is a regular expression (aka regex or regexp), which is a sequence of characters in which each character is either a metacharacter, having a special meaning, or a regular character that has a literal meaning.

source

You can also learn more about regular expression patterns by searching the internet, which has hundreds and thousands of tutorials, courses, & videos.

Hope this helps! If you are still having trouble, please provide more details.

@samliew
P.S.: investing some effort into the tutorials in the Make Academy will save you lots of time and frustration using Make!

1 Like

Hello @Samliew,
I just added your code to my Make.com scenario and it works perfectly.
Thank you for the comprehensive and very detailed explanation.
I’m really happy :slight_smile:
Thank you very much.

1 Like

Hello,
Thank you very much for your reply. I really appreciate your quick response :slight_smile:
It was very clear, but I used @Samliew’s answer :slight_smile:

Hello,
Thank you so much. I really appreciate your quick response :slight_smile:

1 Like