Str.replace only replacing first instance

when using the str.replace function it only replaces the first instance found.

Any ideas?


var str = ${t}; return str.replace("%20"," ")

End up with this

F ““Screen Shot%202019-10-28%20at%204.32.19%20PM.png””


Your function “replace” in Javascript is only ONCE without global modifier.

Example with global modifier in Kantu:

  "Name": "test-replace",
  "CreationDate": "2019-10-30",
  "Commands": [
      "Command": "store",
      "Target": "Screen%20Shot%202019-10-28%20at%204.32.19%20PM.png",
      "Value": "t"
      "Command": "executeScript_Sandbox",
      "Target": "var str = ${t}; return str.replace(/%20/g,\" \");",
      "Value": "result"
      "Command": "echo",
      "Target": "${result}",
      "Value": ""
1 Like

THANK YOU, that did the trick