Created
February 18, 2018 16:35
-
-
Save AyrA/d89118806e46ffe90f3fe6900224f2dd to your computer and use it in GitHub Desktop.
Find and count multiple words on a website
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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