string#

Core function for string data type.

async idem_core_functions.exec.core.string.replace(hub, data: str, to_replace: str, replace_with: str) Dict[source]#

Replace all occurrences of the given substring with another substring in the given string.

Parameters:
  • data (str) – String in which substring to be replaced

  • to_replace (str) – substring to replace in the given string

  • replace_with (str) – substring to replace with in the given string

Returns:

{"result": True|False, "comment": list, "ret": None|dict}

Examples

Calling this exec module function from the cli

idem exec core.string.replace data="test_data" to_replace="test" replace_with="test_updated"

Using in a state:

Idem-state-name:
  exec.run:
    - path: core.string.replace
    - kwargs:
        data: test_data
        to_replace: test
        replace_with: test_updated