Function replace

Replaces all occurrences of the keys in the replaceMap with the values.

replace("Hello, %name%!", { "%name%: "John" }) // "Hello, John!"
replace("Hello, %name%! Nice to meet you %name%!", { "%name%": "Jane" }) // "Hello, Jane! Nice to meet you Jane!"
  • Parameters

    • source: string

      source string

    • replaceMap: Record<string, string>

      keys from this object will be replaced with values in source string

    Returns string