const regex = /(?!<\/a|<\/h1)((<)(\/|)([a-zA-Z-Z0-9]+))/g;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(?!<\\\/a|<\\\/h1)((<)(\\\/|)([a-zA-Z-Z0-9]+))', 'g')
const str = `<!-- Comments Testing -->
<div id="page"><div id="header"><h1><a href="#">Burger Pointer</a></h1><ul class="left"><li><a href="#">Menu</a></li><li><a href="#">Location</a></li><li><a href="#">About Us</a></li><li><a href="#">BP Gear</a></li></ul></div></div>`;
const subst = `\n\1`;
// The substituted value will be contained in the result variable
const result = str.replace(regex, subst);
console.log('Substitution result: ', result);
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