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