# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"\s*<Title\svodBackOfficeId=\"([^\s]*)\">"
test_str = ("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<Titles xmlns=\"urn:eventis:prodis:onlineapi:2.0\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n"
" <Title vodBackOfficeId=\"00181253-684f-4911-92ab-91859bc4402a\">\n"
" <IngestId>1001_00000000071p1</IngestId>\n"
" <Name>Superbabies: Baby Geniuses 2 71</Name>\n"
" <Description>A group of smart-talking toddlers find themselves at the center of a media moguls experiment to crack the code to baby talk. The toddlers must race against time for the sake of babies everywhere.</Description>\n"
" <ContentProvider>Arrivo</ContentProvider>\n"
" <CurrentTitleType>Feature</CurrentTitleType>\n"
" <IsApp>false</IsApp>\n"
" <Assets>\n"
" <Asset vodBackOfficeId=\"dc640b52-3067-4ba2-8506-474996126089\" encodingProfileCode=\"Cable\"/>\n"
" <Asset vodBackOfficeId=\"0a36f3c4-1484-4631-be26-f01a955966ae\" encodingProfileCode=\"Orion\"/>\n"
" <Asset vodBackOfficeId=\"00a0cca8-9d09-4048-bf17-e51b63bb1491\" encodingProfileCode=\"Widevine\"/>\n"
" </Assets>\n"
" <MetadataIngestId>1001_00000000071p1</MetadataIngestId>\n"
" </Title>\n"
" <Title vodBackOfficeId=\"c4289c39-b92f-49c5-9a45-bc6eaf7b8393\">\n"
" <IngestId>9110_00000000175p1</IngestId>\n"
" <Name>SmartRec Test VOD 1</Name>\n"
" <Description>The Tramp cares for an abandoned child, but events put that relationship in jeopardy. Dennis</Description>\n"
" <ContentProvider>Arrivo</ContentProvider>\n"
" <CurrentTitleType>Feature</CurrentTitleType>\n"
" <IsApp>false</IsApp>\n"
" <Assets>\n"
" <Asset vodBackOfficeId=\"39779bf2-800f-4821-8d43-b42dffe155f9\" encodingProfileCode=\"Cable\"/>\n"
" <Asset vodBackOfficeId=\"9c90a157-875e-4737-936e-3d34b60a6b61\" encodingProfileCode=\"Orion\"/>\n"
" <Asset vodBackOfficeId=\"13fb314b-332c-4633-9334-d294f72e370b\" encodingProfileCode=\"Widevine\"/>\n"
" </Assets>\n"
" <MetadataIngestId>9110_00000000175p1</MetadataIngestId>\n"
" </Title>\n"
" <Title vodBackOfficeId=\"4a8bc282-8bb8-4dce-b2d1-e2129c092d80\">\n"
" <IngestId>seachange.com_TEST1386088695671341</IngestId>\n"
" <Name>Wanted</Name>\n"
" <Description>Doormat Wesley Gibson discovers that his recently murdered father -- who Wesley never knew -- belonged to a secret guild of assassins. After a leather-clad sexpot drafts Wesley into the society, he hones his innate killing skills and turns avenger.</Description>\n"
" <ContentProvider>SEAC</ContentProvider>\n"
" <CurrentTitleType>Feature</CurrentTitleType>\n"
" <IsApp>false</IsApp>\n"
" <Assets>\n"
" <Asset vodBackOfficeId=\"b0c8bdd7-00e3-4ce5-889b-73e708d75f03\" encodingProfileCode=\"Cable\"/>\n"
" </Assets>\n"
" <MetadataIngestId>seachange.com_TEST1386088695671341</MetadataIngestId>\n"
" </Title>")
matches = re.finditer(regex, test_str)
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