melonjs
    Preparing search index...

    Function replace

    • Replaces text in a string, using a regular expression or search string.

      Parameters

      • searchValue: string | RegExp

        A string or regular expression to search for.

      • replaceValue: string

        A string containing the text to replace. When the searchValue is a RegExp, all matches are replaced if the g flag is set (or only those matches at the beginning, if the y flag is also present). Otherwise, only the first match of searchValue is replaced.

      Returns string

    • Replaces text in a string, using a regular expression or search string.

      Parameters

      • searchValue: string | RegExp

        A string to search for.

      • replacer: (substring: string, ...args: any[]) => string

        A function that returns the replacement text.

      Returns string

    • Passes a string and replaceValue to the [Symbol.replace] method on searchValue. This method is expected to implement its own replacement algorithm.

      Parameters

      • searchValue: { "[replace]"(string: string, replaceValue: string): string }

        An object that supports searching for and replacing matches within a string.

      • replaceValue: string

        The replacement text.

      Returns string

    • Replaces text in a string, using an object that supports replacement within a string.

      Parameters

      • searchValue: {
            "[replace]"(
                string: string,
                replacer: (substring: string, ...args: any[]) => string,
            ): string;
        }

        A object can search for and replace matches within a string.

      • replacer: (substring: string, ...args: any[]) => string

        A function that returns the replacement text.

      Returns string