Skip to content

Instantly share code, notes, and snippets.

@AyrA
Created February 18, 2018 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AyrA/d89118806e46ffe90f3fe6900224f2dd to your computer and use it in GitHub Desktop.
Save AyrA/d89118806e46ffe90f3fe6900224f2dd to your computer and use it in GitHub Desktop.
Find and count multiple words on a website
(function (x) {
var text = document.body.textContent;
return x.map(function (v) {
var m = text.match(new RegExp("\\s(" + v + ")[\\s.,!?]", "gi"));
return m ? m.length : 0;
});
})(["add", "all", "your", "words", "here"]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment