JSFiddle - React, Tailwind, and code Playground
HTML
<div>i like stackoverflow</div>
<div>i don't like stacKoVerflow</div>
<div>i hate stackoverflow</div>
<div>like stackoverflow</div>
JavaScript
$(function() {
$("div").each(function(index, el) {
var text = $(el).text();
var stringToLookFor = "I like stackoverflow";
var words = stringToLookFor.split(" ");
var match=true;
$.each(words, function(index, word) {
if(!text.match(eval("/\\b" + word + "\\b/i"))) {
match=false;
return false;
}
});
if(match) {
$(el).html("'" + text + "' matched");
} else {
$(el).html("'" + text + "' not matched");
}
});
});