Function replace

  • It will replace matches for the searchValue in the string with the replaceValue.

    Parameters

    • string: string
    • searchValue: string | RegExp
    • replaceValue: string | ((substring, ...args) => string)
    • all: boolean = false

    Returns string

    Since

    1.0.0

    Example

    replace("Hi Fred, I'm Fred!", "Fred", "Barney");
    // => "Hi Barney, I'm Fred!"

    Example

    replace("Hi Fred, I'm Fred too!", "Fred", "Barney", true);
    // => "Hi Barney, I'm Barney too!"