Function replace

Replaces occurrences of a search value with a replace value in a string.

const source = 'Hello, world!';
const searchValue = 'world';
const replaceValue = 'John';
replace(searchValue, replaceValue)(source) // 'Hello, John!'
  • Parameters

    • searchValue: string | RegExp
    • replaceValue: string

    Returns (str: string) => string