Multiple replace what is the best solution to manage a large amount of replacements?

Use javascript’s .replace() method, stringing multiple replace’s together. ie:

var somestring = "foo is an awesome foo bar foo foo"; //somestring lowercase
var replaced = somestring.replace(/foo/g, "bar").replace(/is/g, "or");
// replaced now contains: "bar or an awesome bar bar bar bar"

This code will be run inside executescript_sandbox with ${in} and ${out} variables.

  • executescript_sandbox | var somestring = ${in}; var replaced = somestring.replace(/foo/g, “bar”).replace(/is/g, “or”); return replaced | out
1 Like