I need help in making this function be able to replace not only a single word ("apple" to "orange"), but a whole sentence too ("eat apple" to "sleep well"), both for regular and UPPERCASE. I've tried this :
const re = /eat_apple/gi;
const str = "eat apple";
const replacer = (match) => {
    if(match === "eat apple") {
        return "sleep well";
    }
    else if(match === "EAT APPLE") {
        return "SLEEP WELL";
    }
    else {
        return "eat apple";
    }
}
 
     
    