How to use match javascript for search specific word ?
By this code I want to alert not found
function check() {
  var str = "abcdefg";
  if (str.match(/abc/)) {
    alert("found");
  } else {
    alert("not found");
  }
}
<div onclick="check()">CLICK HERE</div>
And for this code I want to alert found
function check() {
  var str = "abc";
  if (str.match(/abc/)) {
    alert("found");
  } else {
    alert("not found");
  }
}
<div onclick="check()">CLICK HERE</div>
How can I do this?