# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"(<h5\>Atores<\/h5\>\s*)"
test_str = ("<div id=\"left-stack\">\n"
" \n"
" <div parental-rating=\"1\" rating-movie=\"200,br-movie\" class=\"lockup product movie video\">\n"
" <a href=\"https://itunes.apple.com/br/movie/alem-da-escuridao-star-trek/id643978126\">\n"
" <div class=\"artwork\">\n"
" <img width=\"151\" height=\"227\" alt=\"Além da Escuridão: (Star Trek Into Darkness)\" src-swap-high-dpi=\"http://a5.mzstatic.com/us/r30/Video69/v4/6a/7e/3a/6a7e3afe-fa95-e281-84e6-51c532b5b425/poster454x454.jpeg\" src-load-auto-after-dom-load=\"\" src-swap=\"http://a4.mzstatic.com/us/r30/Video69/v4/6a/7e/3a/6a7e3afe-fa95-e281-84e6-51c532b5b425/poster227x227.jpeg\" class=\"artwork\" src=\"https://s.mzstatic.com/htmlResources/3953/frameworks/images/p.png\" />\n"
" <meta itemprop=\"image\" content=\"http://a4.mzstatic.com/us/r30/Video69/v4/6a/7e/3a/6a7e3afe-fa95-e281-84e6-51c532b5b425/poster227x227.jpeg\"></meta></div></a>\n"
" <a onclick=\"return its.detect.openItunes('https://itunes.apple.com/br/movie/alem-da-escuridao-star-trek/id643978126');\" href=\"#\" class=\"action view-in-itunes\"><span>Ver no iTunes</span></a>\n"
" <ul class=\"list\">\n"
" <li><span itemscope itemtype=\"http://schema.org/Offer\" itemprop=\"offers\" class=\"price\"><span itemprop=\"price\" content=\"USD 19.99\">USD 19.99</span></span></li>\n"
" <li class=\"genre\"><span class=\"label\">Gênero: </span><a href=\"https://itunes.apple.com/br/genre/filmes-ficcao-cientifica-e/id4413\">\n"
" <span itemprop=\"genre\">Ficção científica e fantasia</span></a></li>\n"
" <li class=\"release-date\"><span class=\"label\">Lançado: </span><span itemprop=\"dateCreated\" content=\" 17/05/2013\">2013</span></li><li class=\"copyright\">© 2013 Paramount Pictures Corporation. All Rights Reserved.</li></ul>\n"
"</div>")
matches = re.search(regex, test_str)
if matches:
print ("Match was found at {start}-{end}: {match}".format(start = matches.start(), end = matches.end(), match = matches.group()))
for groupNum in range(0, len(matches.groups())):
groupNum = groupNum + 1
print ("Group {groupNum} found at {start}-{end}: {group}".format(groupNum = groupNum, start = matches.start(groupNum), end = matches.end(groupNum), group = matches.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