Skip to content

Instantly share code, notes, and snippets.

@gilchris
Created January 8, 2021 18:55
Show Gist options
  • Save gilchris/3183a2058898a9a92aa2a90f39dc75c2 to your computer and use it in GitHub Desktop.
Save gilchris/3183a2058898a9a92aa2a90f39dc75c2 to your computer and use it in GitHub Desktop.
Extracting script in HTML
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