Tweakr
    Preparing search index...

    Function replaceAll

    • Replaces all occurrences of a substring or pattern in a string.

      Parameters

      • str: string

        The original string.

      • search: string | RegExp

        The substring or regular expression to search for.

      • replace: string

        The string to replace matches with.

      Returns string

      A new string with all matches replaced.

      1.1.0

      replaceAll("hello world", "l", "L"); // "heLLo worLd"
      replaceAll("foo bar foo", /foo/g, "baz"); // "baz bar baz"