Created
January 8, 2021 18:55
-
-
Save gilchris/3183a2058898a9a92aa2a90f39dc75c2 to your computer and use it in GitHub Desktop.
Extracting script in HTML
This file contains hidden or 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 extractScript(str) { | |
let r = new RegExp(/<script[\s\S]*?>([\s\S]+?)<\/script>/mig); | |
return str.match(r) | |
.map(function (s) { | |
return s.replace(r, "$1"); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment