const regex = /<script(?:\s+(?>"[\S\s]*?"|'[\S\s]*?'|(?:(?!\/>)[^>])?)+)?\s*>[\S\s]*?http:\/\/cdn\.walkme\.com\/users[\S\s]*?<\/script\s*(?=>)>/;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('<script(?:\\s+(?>"[\\S\\s]*?"|\'[\\S\\s]*?\'|(?:(?!\\\/>)[^>])?)+)?\\s*>[\\S\\s]*?http:\\\/\\\/cdn\\.walkme\\.com\\\/users[\\S\\s]*?<\\\/script\\s*(?=>)>', '')
const str = `<!DOCTYPE html>
<html lang="en" dir="ltr" class="client-nojs">
<head>
<meta charset="UTF-8" />
<title>International English Language Testing System - Wikipedia, the free encyclopedia</title>
<meta name="generator" content="MediaWiki 1.25wmf2" />
<script type="text/javascript">(function() {var walkme = document.createElement('script'); walkme.type = 'text/javascript'; walkme.async = true; walkme.src='http://cdn.walkme.com/users/cb643dab0d6f4c7cbc9d436e7c06f719/walkme_cb643dab0d6f4c7cbc9d436e7c06f719.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(walkme, s); window._walkmeConfig = {smartLoad:true}; })();</script>
<link rel="alternate" href="android-app://org.wikipedia/http/en.m.wikipedia.org/wiki/International_English_Language_Testing_System" />
<link rel="alternate" type="application/x-wiki" title="Edit this page" href="/w/index.php?title=International_English_Language_Testing_System&action=edit" />
`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
if ((m = regex.exec(str)) !== null) {
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions