const regex = /(?=<tag[^>]*?type=["']findMe["'])/g;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(?=<tag[^>]*?type=["\']findMe["\'])', 'g')
const str = `some html text <br> with some formatting<tag id="1" type="dontFidMe">sample text</tag> yada <tag id="2" type="findMe">sample text</tag>yada`;
const subst = `\n[break]\n`;
// 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