/** * 简单版本的字符串替换函数replaceAll * * 在低版本时提供replaceAll * * @param str * @param search * @param replace * @returns */ declare function replaceAll(str: string, search: string | RegExp, replacer: string | ((substring: string, ...args: any[]) => string)): string; declare global { interface String { /** * Replace all instances of a substring in a string, using a regular expression or search string. * @param searchValue A string to search for. * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ replaceAll(searchValue: string | RegExp, replaceValue: string): string; /** * Replace all instances of a substring in a string, using a regular expression or search string. * @param searchValue A string to search for. * @param replacer A function that returns the replacement text. */ replaceAll(searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; } } export { replaceAll };