# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"<!-- AppInternalsXpert BMX Integration Begin -->(.*[\s\S]*)<!-- AppInternalsXpert BMX Integration End -->"
test_str = ("\n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n\n"
" \n\n"
" \n\n"
" \n"
" \n"
" \n\n"
" \n\n"
" \n\n"
" \n"
" \n\n\n"
" \n"
" \n"
" \n"
" \n"
" \n\n"
" \n"
" \n\n"
" \n\n\n"
" \n"
" \n\n"
" \n"
" \n"
"<script>\n"
"$(function() {\n"
" $( \".tabs\" ).tabs();\n"
" });\n"
"</script>\n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n\n"
" \n\n\n\n\n\n\n\n\n"
" \n"
" \n"
" \n"
" <!-- AppInternalsXpert BMX Integration Begin -->\n"
" <script>\n"
" if(!RVBD_EUE){\n"
" var RVBD_EUE={startJS:Number(new Date()),\n"
" clientId:'',appId:1,\n"
" collector:'apmperformance.correios.com.br',\n"
" collectorHttpPort:80, collectorHttpsPort:443,\n"
" sv:'0401',\n"
" ajax:true, sync:true,\n"
" ajaxResponseTime:true};\n"
" (function(){\n"
" var w=window,l=w.addEventListener,m=w.attachEvent,\n"
" d=document,s='script',t='load',o=RVBD_EUE,\n"
" r=(('https:'===d.location.protocol)?\n"
" 'https://apmperformance.correios.com.br:443':\n"
" 'http://apmperformance.correios.com.br:80')+\n"
" '/jsi/riverbed_appinternals.d.'+\n"
" (o.ajax?'ajax.js':'js'),p=('onpagehide' in w),e=p?'pageshow':t,\n"
" j=d.createElement(s),x=d.getElementsByTagName(s)[0],\n"
" h=function(y){o.ldJS=o.ldJS||new Date();o.per=y?y.persisted:null;},\n"
" i=function(){o.ld=1;};o.cookie=d.cookie;d.cookie=\n"
" '_op_aixPageId=0; path=/; expires='+(new Date(0)).toGMTString();\n"
" o.cookieAfterDelete=d.cookie;j.async=1;j.src=r;\n"
" if(l){l(e,h,false);if(p){l(t,i,false);}}else if(m)\n"
" {m('on'+e,h);if(p){m('on'+t,i);}}\n"
" if(o.sync){d.write('<'+s+' src=\\''+r+'\\'></'+s+'>');}\n"
" else{x.parentNode.insertBefore(j,x);}\n"
" })();}\n"
" </script>\n"
" <script>if(!RVBD_EUE_PARAM){var RVBD_EUE_PARAM={};} RVBD_EUE_PARAM.pageId = 'a2_e6e8c617-d7ec-4acd-a432-08b0febc30e0';</script> \n"
" <!-- AppInternalsXpert BMX Integration End -->\n"
" [cadastrado]\n"
" \n\n"
" \n"
" \n"
" \n"
" ")
matches = re.finditer(regex, test_str, re.IGNORECASE | 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