# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"<div[^>]*data-oembed-url=[\"'](.*?)[\"'].*?>"
test_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>"
matches = re.finditer(regex, test_str, re.IGNORECASE)
for matchNum, match in enumerate(matches, start=1):
print ("Match {matchNum} was found at {start}-{end}: {match}".format(matchNum = matchNum, start = match.start(), end = match.end(), match = match.group()))
for groupNum in range(0, len(match.groups())):
groupNum = groupNum + 1
print ("Group {groupNum} found at {start}-{end}: {group}".format(groupNum = groupNum, start = match.start(groupNum), end = match.end(groupNum), group = match.group(groupNum)))
# Note: for Python 2.7 compatibility, use ur"" to prefix the regex and u"" to prefix the test string and substitution.
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 Python, please visit: https://docs.python.org/3/library/re.html