const regex = /<img[^>]+\>/g;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('<img[^>]+\\>', 'g')
const str = `<p><i>O Armário Amapá da Politorno, essencial e indispensável quando se trata de organização e bom gosto.</i></p>
<p>Disponível na cor:</p>
<p><img class="alignnone" style="display: block; margin-bottom: 30px;" src="https://www.solinemoveis.com.br/wp-content/uploads/2012/09/cores-de-madeira-branco.jpg" alt="cores-de-madeira-branco" width="153" height="189"></p>
<h4>Dimensões do Armário <strong> ARMP3-019 </strong>Amapá:</h4>
<p><img style="display: block; margin-bottom: 30px;" src="https://www.solinemoveis.com.br/wp-content/uploads/2012/09/armario-organizador-amapa-branco-politorno-dimensoes1.jpg" alt="armario-organizador-amapa-branco-politorno-dimensoes1"></p>
<p>Visite também nossa página no facebook: https://www.facebook.com/solinemoveis/</p>
<p><a href="http://www.soline.com.br"><br>
<img class="alignright size-medium" src="https://www.solinemoveis.com.br/wp-content/uploads/2014/09/visite-loja-online-button-soline-moveis-soline.png" alt="Armário Amapá" width="179" height="74"><br>
</a></p>`;
// 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