const regex = /\["(Total|Group1|Group2)",(\d+),\d*,,,,,\d+,\d+\]/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('\\["(Total|Group1|Group2)",(\\d+),\\d*,,,,,\\d+,\\d+\\]', 'gm')
const str = `<!DOCTYPE html>
<html class="main">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Test_Results_20240621_0910</title>
<script type="text/javascript" src="Test_Results_20240621_0910/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="Test_Results_20240621_0910/js/jquery.ui.custom-1.8.7.min.js"></script>
<script type="text/javascript" src="Test_Results_20240621_0910/js/jquery.dynatree-1.2.4.min.js"></script>
<script type="text/javascript" src="Test_Results_20240621_0910/js/jquery.cookie-1.3.1.min.js"></script>
<script type="text/javascript" src="Test_Results_20240621_0910/js/jquery.splitter-1.5.1.min.js"></script>
<script type="text/javascript" src="Test_Results_20240621_0910/js/dotcover.report.js"></script>
<link rel="stylesheet" type="text/css" href="Test_Results_20240621_0910/css/dotcover.report.css">
<link rel="stylesheet" type="text/css" href="Test_Results_20240621_0910/css/dotcover.report.gen.css">
<link rel="stylesheet" type="text/css" href="Test_Results_20240621_0910/css/jquery.dynatree.css">
</head>
<body>
<div class="header"><span class="title">Test_Results_20240621_0910 Coverage Report</span><span class="info">Generated: Friday, June 21, 2024 09:14:13</span></div>
<div class="content" id="content"><div id="coverageTree"></div><iframe id="sourceCode"></iframe></div>
<div class="footer">JetBrains dotCover 2024.1.3 Copyright © 2010-2024 <a href="https://www.jetbrains.com/dotcover/" target="_blank">Product Homepage</a> | <a href="https://www.jetbrains.com/feedback/feedback.jsp?product=dotCover&build=3&timezone=Eastern Standard Time" target="_blank">Feedback</a> | <a href="https://www.jetbrains.com/" target="_blank">Company</a></div>
<script type="text/javascript">
var resourceFolder = "Test_Results_20240621_0910";
var blockSize = 50000;
block0 = [["Total",47,,,,,,1,2],["Group1",29,0,,,,,3,5],["Group2",52,0,,,,,8,4]];
coverageData = [block0];
</script>
</body>
</html>`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// 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