JavaScript
Result
Run
License
class Replacer { constructor(searchString, replaceString) { this.searchString = searchString; this.replaceString = replaceString; } [Symbol.replace](string) { return string.replace(this.searchString, this.replaceString); } } let str = "The grass is always greener on the other side of the fence."; console.log(str.replace(new Replacer("grass", "XXX")));
Console
expand_less
License
License
by DevDic
Close