Ed1
November 5, 2024, 9:49am
1
Hi, I have a string and I want to replace all dash characters (“-”) with the space character (" "), using the SetVariable module.
Prior to the SetVariable module I have run the data through a toString Module.
The SetVariable module looks like this:
replace(VARIABLE; “-”; " ")
But the text is never changing.
What should I be doing?
Thanks for the help in advance!
----UPDATE----
I’ve fixed it using:
replace(VARIABLE; -; space)
where ‘space’ is one of the selectable keywords within Make’s functions.
Hello,
That’s excellent that you’ve fixed it.
While you using Make functions you’ve to follow proper syntax and data type as well.
{{replace("hello-world-with-dashes"; "-"; space)}}
You can also use SPACE instead of " ".
Don’t worry just copy my formula it will automatically work as per make’s function syntax.
After copy/paste, Just change the string to your variable.
P.S.: Always search first, Check Make Academy . If this is helpful, mark it as a solution and Need expert help or have questions? Contact or comment below!
2 Likes
Ed1
November 5, 2024, 10:39am
4
Thank you, I’ve got it working as I need for 1 character change, but I’m trying to fix it for 2 character changes using a nested replace function.
It’s not quite working though, so how about this new problem. Can you help?
I am trying to now replace both commas “,” and spaces " " in one go:
replace(
replace(
“hello world, with spaces, and commas”;
“,”;
emptystring);
“hello world, with spaces, and commas”;
space;
“-”
)
so that the result should be
“hello-world-with-spaces-and-commas”
Hello,
Try this.
Just for reference
{{replace("hello world, with spaces, and commas"; "/[\s,]+/g"; "-")}}
Regular expression build using this check expression
2 Likes