const regex = /(?s)c0"><span>(?<Ref>.+?)<\/.+nowrap;">(?<PartName>.+?)<\/.+itemnum(?:new)?">(?<ItemNumber>.+?)<\/.+dbl">(?<Price>.+?)<\/.+input" value="(?<Quantity>.+?)"/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(?s)c0"><span>(?<Ref>.+?)<\\\/.+nowrap;">(?<PartName>.+?)<\\\/.+itemnum(?:new)?">(?<ItemNumber>.+?)<\\\/.+dbl">(?<Price>.+?)<\\\/.+input" value="(?<Quantity>.+?)"', 'gm')
const str = `<div class="partlistrow">
<form action="/cart/addoempart" data-name="Valve, Intake" data-qoh="0" data-sku="5NL-12111-00-00" id="add_1_5NL-12111-00-00" method="post">
<input type="hidden" id="manf_1" name="manf" value="YAM" />
<input type="hidden" id="assembly_1" name="assembly" value="500449cff8700209bc790600" />
<input type="hidden" id="sku_1" name="sku" value="5NL-12111-00-00" />
<div class="c0"><span>1</span></div>
<div class="c1">
<div class="c1a" style="width:100%;display:table;table-layout:fixed;">
<span style="white-space: nowrap;">Valve, Intake</span>
</div>
<div class="clear"></div>
<div class="c1b">
<a href="/oemparts/p/yamaha/5nl-12111-00-00/valve-intake"><span class="itemnumstrike">5NL-12111-00-00</span></a> <a href="/oemparts/p/yamaha/5nl-12111-30-00/valve-intake"><span class="itemnumnew">5NL-12111-30-00</span></a>
</div>
<div class="clear"></div>
</div>
<div class="c2"><span class="dbl">\$116.99</span></div>
<div class="c3"><input type="text" id="qty_1" name="qty" class="input_1 center required qtyinput" value="1" /></div>
<div class="c4"><input type="submit" id="addtocart_1_5NL-12111-00-00" class="ui ui-icon-smadd btnpartadd" value="Add" /></div>
<div class="clear"></div>
</form>
</div>`;
// 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