String search ".startsWith" and ".includes"

:fox_face: startsWith () is an ES6 feature so it does not run in the “updated” executeScript_Sandbox.

The ES5 replacement of “startsWith” is lastIndexOf ("startsWithThis", 0) === 0

Example: We test if the string starts with “fox” :fox_face::

{
  "Name": "lastindexof",
  "CreationDate": "2022-5-18",
  "Commands": [
    {
      "Command": "store",
      "Target": "fox fox fox",
      "Value": "searchme",
      "Description": ""
    },
    {
      "Command": "store",
      "Target": "fox",
      "Value": "searchfor",
      "Description": ""
    },
    {
      "Command": "executeScript_Sandbox",
      "Target": "var haystack1 = ${searchme}; var needle = ${searchfor};  return (haystack1.lastIndexOf(needle, 0) === 0);",
      "Value": "result",
      "Description": ""
    },
    {
      "Command": "echo",
      "Target": "${result} ",
      "Value": "green",
      "Description": "TRUE because the string starts with FOX"
    },
    {
      "Command": "store",
      "Target": "ox",
      "Value": "searchfor",
      "Description": "Try again with a new search string"
    },
    {
      "Command": "executeScript_Sandbox",
      "Target": "var haystack1 = ${searchme}; var needle = ${searchfor};  return (haystack1.lastIndexOf(needle, 0) === 0);",
      "Value": "result",
      "Description": ""
    },
    {
      "Command": "echo",
      "Target": "${result} ",
      "Value": "blue ",
      "Description": "FALSE because the string does NOT start with FOX"
    },
    {
      "Command": "store",
      "Target": "fox",
      "Value": "searchfor",
      "Description": "Now use it inside IF"
    },
    {
      "Command": "if_v2",
      "Target": "${searchme}.lastIndexOf(${searchfor}, 0) === 0",
      "Value": "",
      "Description": "test if string SEARCHME starts with SEARCHFOR"
    },
    {
      "Command": "echo",
      "Target": "string found!",
      "Value": "green",
      "Description": ""
    },
    {
      "Command": "else",
      "Target": "",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "echo",
      "Target": "string NOT found!",
      "Value": "pink",
      "Description": ""
    },
    {
      "Command": "end",
      "Target": "",
      "Value": "",
      "Description": ""
    }
  ]
}