Replace a string in var

This is the solution

Code:

{
  "Name": "Replace",
  "CreationDate": "2020-9-11",
  "Commands": [
    {
      "Command": "store",
      "Target": "10.09.2020",
      "Value": "MyValue"
    },
    {
      "Command": "echo",
      "Target": "${MyValue}",
      "Value": "#shownotification"
    },
    {
      "Command": "executeScript_Sandbox",
      "Target": "var mystring = ${MyValue}; var replaced = mystring.replace(/\\./g,''); return replaced",
      "Value": "MyValue"
    },
    {
      "Command": "echo",
      "Target": "${MyValue}",
      "Value": "#shownotification"
    }
  ]
}

Log

[status]

Playing macro Replace

[info]

Executing: | store | 10.09.2020 | MyValue |

[info]

Executing: | echo | ${MyValue} | #shownotification |

[echo]

10.09.2020

[info]

Executing: | executeScript_Sandbox | var mystring = ${MyValue}; var replaced = mystring.replace(/./g,’’); return replaced | MyValue |

[info]

Executing: | echo | ${MyValue} | #shownotification |

[echo]

10092020

[info]

Macro completed (Runtime 1.37s)

1 Like