use strict;
my $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>';
my $regex = qr/<div[^>]*data-oembed-url=["'](.*?)["'].*?>/ip;
if ( $str =~ /$regex/g ) {
print "Whole match is ${^MATCH} and its start/end positions can be obtained via \$-[0] and \$+[0]\n";
# print "Capture Group 1 is $1 and its start/end positions can be obtained via \$-[1] and \$+[1]\n";
# print "Capture Group 2 is $2 ... and so on\n";
}
# ${^POSTMATCH} and ${^PREMATCH} are also available with the use of '/p'
# Named capture groups can be called via $+{name}
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 Perl, please visit: http://perldoc.perl.org/perlre.html