A default string replace function with the default options.
Replace ${key} using object as key to value mapping
${key}
import {replace} from "apprt-core/string-replace";const msg = replace("${name} says ${msg}", { msg: "hello" });msg === "${name} says hello"; // true Copy
import {replace} from "apprt-core/string-replace";const msg = replace("${name} says ${msg}", { msg: "hello" });msg === "${name} says hello"; // true
Replacing ${key} using custom value lookup function
import {replace} from "apprt-core/string-replace";const msg = replace("${name} says ${msg}", (key) => key === "msg" ? "hello" : "");msg === " says hello"; // true Copy
import {replace} from "apprt-core/string-replace";const msg = replace("${name} says ${msg}", (key) => key === "msg" ? "hello" : "");msg === " says hello"; // true
the string template
Optional
record of values or a lookup function
a string with all ${key} expressions replaced by matching values in valueLookup.
valueLookup
A default string replace function with the default options.
Example
Replace
${key}
using object as key to value mappingExample
Replacing
${key}
using custom value lookup function