Sanitizing strings

I have a webhook collecting form data.

I am trying to sanitize the string with the text parser to remove Tabs, New-lines, and more the 4 consecuctives space. I am using this regex (\\n|\\t| {5,})

My input string is as follows: "why": "We enjoyed the whole day! Carlo looked after us very well with good knowledge and briefings. \n\nBike quality/maintenance. "

And my module looks like this:

It’s not working, I probably got it wrong… can someone put me in the right direction

first of all you need to check “global match” = yes because you don’t want it to stop after the first match.
And for the new value: if you put “” here, you will get “” instead of nothing. Use the pink emptystring from “Text and binary functions” instead.

Is the string that you postet what gets fed into the “replace” module? So you have actual \n \n in the string and not two new lines?

1 Like

Correct I have the /n string coming in the webhook. it’s then interpreted as new lines by make.com and being forwarded to WhatsApp Business module, which fails because it can’t deal with new lines

I tried getting rid off the empty lines / new lines but I am not good with regex so I did it the way I would do it, which is using functions to first split the string up using newline as a separator and then joining the items of that array into one string using emptystring as separator.

You can do this right in the “Replace” module.

Does this help?

1 Like

Changing the pattern to (\n|\t| {5,}) also worked for me!

I used this as an input value:

"why":       "We enjoyed the whole day! Carlo looked after us very well with good knowledge and briefings.


Bike quality/maintenance. "

and got this as output:

"why":"We enjoyed the whole day! Carlo looked after us very well with good knowledge and briefings.Bike quality/maintenance. "

Thanks so much John, removing the escaping (literal string) of the regex works.

1 Like