# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"(<script[\s\S]*?src[\s\S]*?\=[\s\S]+?\"[/a-zA-Z0-9._-]*\.hyperesources[/a-zA-Z0-9._-]*\.min.js\"[\s\S\]*?>[\s\S]*?<\/script>)"
test_str = ("<!DOCTYPE html>\n"
"<html>\n"
" <head>\n"
" <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n"
" <meta http-equiv=\"X-UA-Compatible\" content=\"chrome=1,IE=edge\" />\n"
" <title>Default</title>\n"
" <style>\n"
" html {\n"
" height:100%;\n"
" }\n"
" body {\n"
" background-color:#FFFFFF;\n"
" margin:0;\n"
" height:100%;\n"
" }\n"
" </style>\n"
" <!-- copy these lines to your document head: -->\n\n"
" <meta name=\"viewport\" content=\"user-scalable=no, initial-scale=1.0, width=375\" />\n"
" <meta name=\"apple-mobile-web-app-capable\" content=\"yes\" />\n"
" <script src = \"Default.hyperesources/HYPE-584.thin.min.js\"></script>\n\n"
" <!-- end copy -->\n"
" </head>\n"
" <body>\n"
" <!-- copy these lines to your document: -->\n\n"
" <div id=\"default_hype_container\" style=\"margin:auto;position:relative;width:375px;height:667px;overflow:hidden;\">\n"
" </div>\n\n"
" <!-- end copy -->\n"
" <script type=\"text/javascript\" charset=\"utf-8\">\n"
" // HYPE.documents[\"Default\"]\n\n"
"(function(){(function k(){function l(a,b,d){var c=!1;null==window[a]&&(null==window[b]?(window[b]=[],window[b].push(k),a=document.getElementsByTagName(\"head\")[0],b=document.createElement(\"script\"),c=h,false==!0&&(c=\"\"),b.type=\"text/javascript\",b.src=c+\"/\"+d,a.appendChild(b)):window[b].push(k),c=!0);return c}var h=\"Default.hyperesources\",c=\"Default\",e=\"default_hype_container\";if(false==!1)try{for(var f=document.getElementsByTagName(\"script\"),\n"
"a=0;a<f.length;a++){var b=f[a].src,d=null!=b?b.indexOf(\"/default_hype_generated_script.js\"):-1;if(-1!=d){h=b.substr(0,d);break}}}catch(n){}if(false==!1&&(a=navigator.userAgent.match(/MSIE (\\d+\\.\\d+)/),a=parseFloat(a&&a[1])||null,a=l(\"HYPE_584\",\"HYPE_dtl_584\",!0==(null!=a&&10>a||false==!0)?\"HYPE-584.full.min.js\":\"HYPE-584.thin.min.js\"),false==!0&&(a=a||l(\"HYPE_w_584\",\"HYPE_wdtl_584\",\"HYPE-584.waypoints.min.js\")),a))return;f=window.HYPE.documents;\n"
"if(null!=f[c]){b=1;a=c;do c=\"\"+a+\"-\"+b++;while(null!=f[c]);d=document.getElementsByTagName(\"div\");b=!1;for(a=0;a<d.length;a++)if(d[a].id==e&&null==d[a].getAttribute(\"HYP_dn\")){var b=1,g=e;do e=\"\"+g+\"-\"+b++;while(null!=document.getElementById(e));d[a].id=e;b=!0;break}if(!1==b)return}b=[];b=[];d={};g={};for(a=0;a<b.length;a++)try{g[b[a].identifier]=b[a].name,d[b[a].name]=eval(\"(function(){return \"+b[a].source+\"})();\")}catch(m){window.console&&window.console.log(m),d[b[a].name]=\n"
"function(){}}a=new HYPE_584(c,e,{\"3\":{p:1,n:\"time%20change_2x.png\",g:\"16\",o:true,t:\"@2x\"},\"1\":{p:1,n:\"tag_layout_2x.jpg\",g:\"10\",o:true,t:\"@2x\"},\"2\":{p:1,n:\"time%20change.png\",g:\"16\",o:true,t:\"@1x\"},\"0\":{p:1,n:\"tag_layout.jpg\",g:\"10\",o:true,t:\"@1x\"}},h,[],d,[{n:\"Untitled Scene\",o:\"1\",X:[0]}],[{o:\"3\",p:\"600px\",cA:false,Y:375,Z:667,L:[],c:\"#FFFFFF\",bY:1,d:375,U:{\"47\":{V:{\"Main Timeline\":\"60\"},W:\"60\",n:\"inputsymbol\"}},T:{\"60\":{c:\"47\",z:0,i:\"60\",n:\"Main Timeline\",a:[],f:30,b:[]},kTimelineDefaultIdentifier:{i:\"kTimelineDefaultIdentifier\",n:\"Main Timeline\",z:1,b:[{D:0,H:true,E:true,z:false,F:0,G:0,C:0.21,b:\"60\"}],a:[{f:\"c\",y:0,z:0.1,i:\"c\",e:48,s:24,o:\"58\"},{f:\"c\",y:0,z:0.1,i:\"d\",e:48,s:24,o:\"58\"},{f:\"c\",y:0,z:0.1,i:\"e\",e:0.76705893987341767,s:0,o:\"58\"},{f:\"c\",y:0,z:0.1,i:\"b\",e:16,s:29,o:\"58\"},{f:\"c\",y:0,z:0.1,i:\"a\",e:325,s:340,o:\"58\"},{f:\"c\",y:0.1,z:0.04,i:\"a\",e:337,s:325,o:\"58\"},{f:\"c\",y:0.1,z:0.04,i:\"b\",e:26,s:16,o:\"58\"},{f:\"c\",y:0.1,z:0.04,i:\"c\",e:28,s:48,o:\"58\"},{f:\"c\",y:0.1,z:0.04,i:\"d\",e:28,s:48,o:\"58\"},{f:\"c\",y:0.1,z:0.04,i:\"e\",e:0,s:0.76705893987341767,o:\"58\"},{f:\"c\",y:0.14,z:0.07,i:\"e\",e:1,s:0,o:\"55\"},{y:0.14,i:\"a\",s:337,z:0,o:\"58\",f:\"c\"},{y:0.14,i:\"b\",s:26,z:0,o:\"58\",f:\"c\"},{y:0.14,i:\"c\",s:28,z:0,o:\"58\",f:\"c\"},{y:0.14,i:\"d\",s:28,z:0,o:\"58\",f:\"c\"},{y:0.14,i:\"e\",s:0,z:0,o:\"58\",f:\"c\"},{f:\"c\",y:0.21,z:0.09,i:\"b\",e:105,s:347,o:\"47\"},{y:0.21,i:\"e\",s:1,z:0,o:\"55\",f:\"c\"},{y:1,i:\"b\",s:105,z:0,o:\"47\",f:\"c\"}],f:30}},bZ:180,O:[\"55\",\"53\",\"58\",\"57\",\"51\",\"47\",\"49\",\"56\",\"59\",\"54\",\"48\",\"50\",\"52\"],n:\"Untitled Layout\",\"_\":0,v:{\"57\":{c:373,d:319,I:\"Solid\",J:\"Solid\",K:\"Solid\",g:\"#FFFFFF\",L:\"Solid\",M:1,N:1,A:\"#D8DDE4\",x:\"visible\",j:\"absolute\",B:\"#D8DDE4\",P:1,k:\"div\",C:\"#D8DDE4\",z:5,O:1,D:\"#D8DDE4\",a:0,b:346},\"47\":{x:\"visible\",a:71,cA:false,bX:false,j:\"absolute\",b:347,c:236,k:\"div\",bY:1,d:160,z:4,bZ:180,cV:[]},\"53\":{h:\"10\",p:\"no-repeat\",x:\"visible\",a:0,q:\"100% 100%\",b:0,j:\"absolute\",dB:\"img\",z:2,k:\"div\",c:375,d:667,r:\"inline\",cQ:1,cR:1},\"58\":{c:24,d:24,I:\"Solid\",e:0,J:\"Solid\",K:\"Solid\",g:\"#0096FF\",L:\"None\",M:1,N:1,aI:\"50%\",A:\"#D8DDE4\",x:\"visible\",O:1,j:\"absolute\",aJ:\"50%\",k:\"div\",C:\"#D8DDE4\",z:9,B:\"#D8DDE4\",D:\"#D8DDE4\",aK:\"50%\",P:0,a:340,aL:\"50%\",b:29},\"48\":{c:198,d:38,I:\"Solid\",J:\"Solid\",K:\"Solid\",Y:41,g:\"#E8EBED\",L:\"Solid\",M:1,w:\"9:00\",aI:10,A:\"#D8DDE4\",N:1,O:1,x:\"visible\",aJ:10,j:\"absolute\",C:\"#D8DDE4\",z:12,k:\"div\",D:\"#D8DDE4\",aK:10,B:\"#D8DDE4\",bF:\"47\",P:1,a:17,F:\"center\",aL:10,b:60},\"54\":{G:\"#595959\",aU:8,c:325,aV:8,d:136,r:\"inline\",s:\"'Helvetica Neue',Arial,Helvetica,Sans-Serif\",t:16,Y:24,Z:\"break-word\",w:\"<span style=\\\"font-style: normal;\\\" data-sheets-value=\\\"{"1":2,"2":"Forget to log something from earlier in the day, or even yesterday? Look for the clock icon on the top right for food and drink, details and context, and thinking and feeling logs. If you want to attribute the log to the previous day, just tap the 'for yesterday' option."}\\\" data-sheets-userformat=\\\"{"2":4865,"3":[null,0],"11":4,"12":0,"15":"Helvetica Neue"}\\\">Forget to log something from earlier in the day, or even yesterday? Look for the clock icon on the top right for food and drink, details and context, and thinking and feeling logs. If you want to attribute the log to the previous day, just tap the 'for yesterday' option.</span><br>\",j:\"absolute\",x:\"visible\",k:\"div\",y:\"preserve\",z:8,aS:8,aT:8,a:18,b:409},\"59\":{G:\"#000000\",aU:8,c:264,d:18,aV:8,r:\"inline\",s:\"'Helvetica Neue',Arial,Helvetica,Sans-Serif\",t:21,Z:\"break-word\",v:\"normal\",w:\"Change the time of your log\",A:\"#FFFFFF\",x:\"visible\",j:\"absolute\",B:\"#FFFFFF\",y:\"preserve\",k:\"div\",C:\"#FFFFFF\",z:7,aS:8,D:\"#FFFFFF\",aT:8,a:63,b:369},\"50\":{aV:8,w:\"Cancel<br>\",x:\"visible\",a:20,Z:\"break-word\",b:120,y:\"preserve\",j:\"absolute\",z:14,yy:\"nowrap\",s:\"Helvetica,Arial,Sans-Serif\",aT:8,k:\"div\",bF:\"47\",aS:8,t:16,aU:8,G:\"#0096FF\",r:\"inline\"},\"55\":{c:386,d:666,I:\"Solid\",e:0,J:\"Solid\",K:\"Solid\",g:\"rgba(0, 0, 0, 0.341)\",L:\"None\",aP:\"default\",M:1,N:1,A:\"#D8DDE4\",x:\"visible\",aA:{a:[{i:0,b:\"kTimelineDefaultIdentifier\",p:9,symbolOid:\"2\"},{b:\"kTimelineDefaultIdentifier\",p:3,z:false,symbolOid:\"2\"}]},O:1,j:\"absolute\",k:\"div\",dB:\"button\",z:3,C:\"#D8DDE4\",D:\"#D8DDE4\",B:\"#D8DDE4\",P:0,a:-5,b:0},\"49\":{aV:8,w:\"Change Time\",x:\"visible\",a:61,Z:\"break-word\",b:14,y:\"preserve\",j:\"absolute\",z:11,yy:\"nowrap\",s:\"Helvetica,Arial,Sans-Serif\",aT:8,k:\"div\",bF:\"47\",aS:8,t:16,aU:8,G:\"#000000\",r:\"inline\"},\"51\":{c:234,d:158,I:\"Solid\",J:\"Solid\",K:\"Solid\",g:\"#FFFFFF\",L:\"Solid\",M:1,N:1,aI:10,A:\"#929292\",x:\"visible\",j:\"absolute\",O:1,aJ:10,k:\"div\",C:\"#929292\",z:10,B:\"#929292\",D:\"#929292\",aK:10,bF:\"47\",P:1,a:0,aL:10,b:0},\"56\":{h:\"16\",p:\"no-repeat\",x:\"visible\",a:23,q:\"100% 100%\",b:369,j:\"absolute\",dB:\"img\",z:6,k:\"div\",c:40,d:40,r:\"inline\"},\"52\":{aV:8,w:\"Save\",x:\"visible\",a:159,Z:\"break-word\",b:120,y:\"preserve\",j:\"absolute\",z:13,yy:\"nowrap\",s:\"Helvetica,Arial,Sans-Serif\",aT:8,k:\"div\",bF:\"47\",aS:8,t:16,aU:8,G:\"#0096FF\",r:\"inline\"}}}],{},g,{},null,false,true,-1,true,true,true,false);f[c]=a.API;document.getElementById(e).setAttribute(\"HYP_dn\",\n"
"c);a.z_o(this.body)})();})();\n\n"
" </script>\n"
" \n\n\n"
" <!-- text content for search engines: -->\n\n"
" <div style=\"display:none\" aria-hidden=true>\n\n"
" <div>Forget to log something from earlier in the day, or even yesterday? Look for the clock icon on the top right for food and drink, details and context, and thinking and feeling logs. If you want to attribute the log to the previous day, just tap the 'for yesterday' option.\n"
"</div>\n"
" <div>Change the time of your log</div>\n"
" <div>9:00</div>\n"
" <div>Change Time</div>\n"
" <div>Cancel\n"
"</div>\n"
" <div>Save</div>\n\n"
" </div>\n\n"
" <!-- end text content: -->\n\n"
" </body>\n"
"</html>")
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