Replace() function not substituting pipe character "|" in SetVariable module

:bullseye: What is your goal?

I need to convert a space-separated string of numbers (e.g. ā€œ1 2 3ā€) into a pipe-separated string (e.g. ā€œ1|2|3ā€) to use as a regex alternation pattern in a Text Parser module.

:thinking: What is the problem & what have you tried?

In a SetVariable (util:SetVariable2) module, I’m using replace(871.$2; " "; ā€œ|ā€) where 871.$2 contains ā€œ1 2 3ā€. The module returns ā€œ1 2 3ā€ unchanged — the pipe character is never substituted. I also tried replace(871.$2; " "; ā€œ|ā€) with quotes, join(split(871.$2; " "); ā€œ|ā€), and putting the replace() directly in the Text Parser pattern field. None of these worked. The replace() works fine with other characters like comma, but not with pipe.

Hey there,

this is because in Make, empty space is not " " its {{space}}. You can also select it from the menu under text and binary functions, at the bottom under keywords. So this:

{{replace(871.$2; space; "|")}}

image

1 Like

Many thanks!. it worked