mirror of
https://github.com/aykhans/slash-e.git
synced 2025-04-17 04:43:13 +00:00
16 lines
397 B
TypeScript
16 lines
397 B
TypeScript
(() => {
|
|
if (!String.prototype.replaceAll) {
|
|
String.prototype.replaceAll = function (str: any, newStr: any) {
|
|
// If a regex pattern
|
|
if (Object.prototype.toString.call(str).toLowerCase() === "[object regexp]") {
|
|
return this.replace(str, newStr);
|
|
}
|
|
|
|
// If a string
|
|
return this.replace(new RegExp(str, "g"), newStr);
|
|
};
|
|
}
|
|
})();
|
|
|
|
export default null;
|