Function strReplaceAll

  • Replaces all occurrences of a substring in a string with a specified replacement.

    Parameters

    • input: string

      The input string.

    • replace: string

      The substring to be replaced.

    • replaceWith: string

      The replacement string.

    • flags: string = 'g'

      Optional. The flags for the regular expression. Defaults to 'g'.

    Returns string

    Example

    const input = 'Hello, world!';
    const replace = 'o';
    const replaceWith = '0';
    strReplaceAll(input, replace, replaceWith);
    //=> 'Hell0, w0rld!'

Generated using TypeDoc