const regex = /\/\*[^*]*\*+([^\/*][^*]*\*+)*\/
/g;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('\\\/\\*[^*]*\\*+([^\\\/*][^*]*\\*+)*\\\/
', 'g')
const str = `/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
/* @TODO:
- Notes...
*/
/* = = = Set Base Font Size = = = So 1em = 10px / 1.8em = 18px etc */
body { font-size: 62.5% }
body, ul, li {
color: #333333;
font-family: 'Open Sans', verdana, arial, helvetica, helve, sans-serif;
font-weight: 400;
/* font-size: 1.4em; Default font = 14px normal weight Open Sans using #333333 */
line-height: 1.25em;
}
body {
margin: 0; /* Nav bar and footer need to fit edge to edge so no margins! */
padding: 0;
top: 0;
border-bottom: 1px #1C1C1C solid; /* To remove white space under the popup footer */
}
/* = = = Typography = = = */
/* Font choice was carefully considered, Open Sans is very popular so many visitors will already have it cached. */
/* Monda & Shadows into light are also quite popular so may be cached too */
/* = = = Headings = = = */
h1, h2, h3, h4, h5, h6 {
font-family: 'Monda', 'Trebuchet MS', verdana, arial, helvetica, helve, sans-serif;
font-weight: 400;
line-height: 1.2em;
letter-spacing: 1px;
color: #333333;
margin-top: 10px;
margin-bottom: 20px;
}
`;
// 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