const regex = new RegExp('<div[^>]*data-oembed-url=["\\'](.*?)["\\'].*?>', 'gi')
const str = `<p><strong>Integer</strong> ante arcu, accumsan a, consectetuer eget, posuere ut, mauris. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc, quis gravida magna mi a <em>libero</em>. In <u>auctor</u> lobortis lacus. Curabitur suscipit suscipit tellus. Fusce convallis metus id felis luctus adipiscing.</p> <div data-oembed-url="https://www.youtube.com/watch?v=WwHy2hotU6c" data-> <div style="left: 0px; width: 100%; height: 0px; position: relative; padding-bottom: 56.2493%;"><iframe allowfullscreen="true" frameborder="0" mozallowfullscreen="true" src="https://www.youtube.com/embed/WwHy2hotU6c?wmode=transparent&rel=0&autohide=1&showinfo=0&enablejsapi=1" style="top: 0px; left: 0px; width: 100%; height: 100%; position: absolute;" webkitallowfullscreen="true"></iframe></div> </div> <ol> <li>Um</li> <li>Dois</li> <li>Três</li> </ol> <div data-oembed-url="http://pt.slideshare.net/josephj/from-hacker-to-programmer-w-webpack-babel-and-react"> <div style="left: 0px; width: 100%; height: 0px; position: relative; padding-bottom: 83.5282%;"><iframe allowfullscreen="true" frameborder="0" mozallowfullscreen="true" src="https://www.slideshare.net/slideshow/embed_code/key/4guX8biZafHvI7" style="top: 0px; left: 0px; width: 100%; height: 100%; position: absolute;" webkitallowfullscreen="true"></iframe></div> </div> <ul> <li>Primeiro</li> <li>Segundo</li> <li>Terceiro</li> </ul> <p>In consectetuer turpis ut velit. Duis lobortis massa imperdiet quam. Curabitur at lacus ac velit ornare lobortis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Suspendisse nisl elit, rhoncus eget, elementum ac, condimentum eget, diam.</p> <p>Suspendisse faucibus, nunc et pellentesque egestas, lacus ante convallis tellus, vitae iaculis lacus elit id tortor. Quisque rutrum. Curabitur blandit mollis lacus. Duis leo. Suspendisse potenti.</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