# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"""
^(((((.+\.)*(msedge))|((((.+\.)*(scsquery\-ss\-us))|((.+\.)*(scsquery\-ss\-eu))|((.+\.)*(scsquery\-ss\-asia))|((.+\.)*(scsinstrument\-ss\-us))|((.+\.)*(skypemaprdsitus)))\.(trafficmanager))|((.+\.)*(msftauth))|((((((((.+\.)*(policykeyservice)))\.(dc)))\.(ad)))\.(msft))|((.+\.)*(phonefactor))|((((((((.+\.)*(informationprotection)))\.(hosting)))\.(portal))|((.+\.)*(amp)))\.(azure))|((((((.+\.)*(ecn)))\.(dev)))\.(virtualearth))|((((.+\.)*(apis)))\.(live))|((((.+\.)*(spoprod\-a)))\.(akamaihd))|((((.+\.)*(cdn)))\.(onenote))|((.+\.)*(msecnd))|((.+\.)*(msftauthimages))|((((((((.+\.)*(officecdn)))\.(microsoft)))\.(com)))\.(edgesuite))|((.+\.)*(msauth))|((((.+\.)*(mlccdnprod)))\.(azureedge))|((.+\.)*(msauthimages))|((((((.+\.)*(insertmedia)))\.(bing))|((((.+\.)*(videocontent))|((.+\.)*(videoplayercdn))|((.+\.)*(contentstorage))|((.+\.)*(video)))\.(osi))|((((.+\.)*(support)))\.(content))|((.+\.)*(cdn))|((.+\.)*(attachments))|((.+\.)*(suite)))\.(office))|((.+\.)*(windows)))\.(net))|((((((.+\.)*(appsforoffice))|((.+\.)*(c1))|((.+\.)*(crl))|((((.+\.)*(r)))\.(office))|((.+\.)*(aria))|((.+\.)*(technet))|((.+\.)*(officecdn))|((.+\.)*(officeredir))|((.+\.)*(officepreviewredir))|((.+\.)*(office15client))|((.+\.)*(go))|((.+\.)*(msdn))|((((.+\.)*(activation)))\.(sls))|((.+\.)*(support))|((.+\.)*(compass\-ssl))|((.+\.)*(docs))|((((.+\.)*(events)))\.(data))|((.+\.)*(officeclient)))\.(microsoft))|((.+\.)*(outlook))|((.+\.)*(microsoftonline))|((((.+\.)*(secure)))\.(skypeassets))|((.+\.)*(sharepointonline))|((((.+\.)*(informationprotection))|((.+\.)*(management))|((.+\.)*(adhybridhealth)))\.(azure))|((((.+\.)*(g))|((.+\.)*(officeapps))|((((.+\.)*(client)))\.(hip)))\.(live))|((.+\.)*(onenote))|((((.+\.)*(\-myfiles))|((.+\.)*(\-files)))\.(sharepoint))|((((.+\.)*(admin))|((.+\.)*(www)))\.(onedrive))|((.+\.)*(o365weve))|((((.+\.)*(platform)))\.(linkedin))|((.+\.)*(azurerms))|((((.+\.)*(prod))|((.+\.)*(shellprod)))\.(msocdn))|((.+\.)*(microsoftonline\-p))|((((.+\.)*(cdn)))\.(optimizely))|((((.+\.)*(quicktips)))\.(skypeforbusiness))|((((.+\.)*(ajax)))\.(aspnetcdn))|((.+\.)*(aadrm))|((((.+\.)*(products))|((.+\.)*(delve\-gcc))|((.+\.)*(support))|((.+\.)*(templates))|((.+\.)*(outlook))|((.+\.)*(delve))|((((.+\.)*(webshell)))\.(suite)))\.(office))|((.+\.)*(office365))|((.+\.)*(sfbassets))|((((((.+\.)*(skydrive)))\.(wns)))\.(windows))|((.+\.)*(skype)))\.(com))|((((.+\.)*(svc))|((((.+\.)*(auth)))\.(gfx))|((.+\.)*(aka))|((.+\.)*(mstea))|((((.+\.)*(assets)))\.(onestore))|((((.+\.)*(oneclient)))\.(sfx)))\.(ms)))$
"""
test_str = ("aadrm.com\n"
"account.activedirectory.windowsazure.com\n"
"acompli.net\n"
"ad.atdmt.com\n"
"adhybridhealth.azure.com\n"
"adl.windows.com\n"
"ajax.aspnetcdn.com\n"
"aka.ms\n"
"appex-rf.msn.com\n"
"assets.onestore.ms\n"
"assets-yammer.com\n"
"atp.azure.com\n"
"auth.gfx.ms\n"
"autologon.microsoftazuread-sso.com\n"
"azure.net\n"
"azureedge.net\n"
"azurerms.com\n"
"bing.com\n"
"bit.ly\n"
"by.uservoice.com\n"
"c.bing.net\n"
"cdn.optimizely.com\n"
"clientconfig.microsoftonline-p.net\n"
"cloudapp.net\n"
"ctldl.windowsupdate.com\n"
"dc.services.visualstudio.com\n"
"ecn.dev.virtualearth.net\n"
"eus-www.sway-cdn.com\n"
"eus-www.sway-extensions.com\n"
"excelbingmap.firstpartyapps.oaspapps.com\n"
"firstpartyapps.oaspapps.com\n"
"graph.facebook.com\n"
"hockeyapp.net\n"
"informationprotection.azure.com\n"
"isrg.trustid.ocsp.identrust.com\n"
"live.com\n\n"
"live.net\n"
"login.windows-ppe.net\n"
"lync.com\n"
"management.azure.com\n"
"mem.gfx.ms\n"
"microsoft.com\n\n\n\n\n\n\n\n\n"
"microsoftonline.com\n\n\n\n\n\n\n\n\n\n\n\n"
"microsoftonline-p.com\n\n"
"microsoftstream.com\n"
"msappproxy.net\n"
"msauth.net\n"
"msauthimages.net\n"
"msecnd.net\n"
"msedge.net\n"
"msftauth.net\n"
"msftauthimages.net\n"
"msftidentity.com\n"
"msidentity.com\n"
"msocdn.com\n"
"mstea.ms\n"
"o365weve.com\n"
"office.com\n\n\n\n\n\n\n\n\n\n\n"
"office.net\n"
"office365.com\n\n"
"officecdn.microsoft.com.edgesuite.net\n"
"oneclient.sfx.ms\n"
"onedrive.com\n"
"onenote.com\n"
"onmicrosoft.com\n"
"outlook.com\n\n"
"outlook.uservoice.com\n"
"outlookmobile.com\n"
"partnerservices.getmicrosoftkey.com\n"
"peoplegraph.firstpartyapps.oaspapps.com\n"
"phonefactor.net\n"
"policykeyservice.dc.ad.msft.net\n"
"portal.cloudappsecurity.com\n"
"prod.firstpartyapps.oaspapps.com.akadns.net\n"
"secure.skypeassets.com\n"
"sfbassets.com\n"
"sharepoint.com\n"
"sharepointonline.com\n"
"skydrive.wns.windows.com\n"
"skype.com\n\n"
"skypeforbusiness.com\n"
"social.yahooapis.com\n"
"spoprod-a.akamaihd.net\n"
"staffhub.ms\n"
"staffhub.uservoice.com\n"
"svc.ms\n"
"sway.com\n"
"symcb.com\n"
"symcd.com\n"
"telemetryservice.firstpartyapps.oaspapps.com\n"
"trafficmanager.net\n"
"tse1.mm.bing.net\n"
"view.atdmt.com\n"
"wikipedia.firstpartyapps.oaspapps.com\n"
"windows.net\n\n\n"
"windowsupdate.com\n"
"wus-firstpartyapps.oaspapps.com\n"
"wus-www.sway-cdn.com\n"
"wus-www.sway-extensions.com\n"
"yammer.com\n"
"yammerusercontent.com\n")
matches = re.finditer(regex, test_str, re.VERBOSE | re.MULTILINE)
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