# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"3Dcache*:().*%252B"
test_str = ("<li class=\"g\"><h3 class=\"r\"><a href=\"http://maps.google.com/maps?um=1&ie=UTF-8&fb=1&gl=us&cid=12546501552342514458&q=Malheur+National+Forest&sa=X&ei=tsCpU7y-HM28oQSa9IIQ&ved=0CBUQtQMwAA\"><div>Map for <b>Malheur National Forest</b></div></a></h3><div class=\"mlmcm\" style=\"margin:16px 0\"><a href=\"http://maps.google.com/maps?um=1&ie=UTF-8&fb=1&gl=us&cid=12546501552342514458&q=Malheur+National+Forest&sa=X&ei=tsCpU7y-HM28oQSa9IIQ&ved=0CBYQtgMwAA\"><img height=\"233\" src=\"/maps/vt/data=VLHX1wd2Cgu8wR6jwyh-km8JBWAkEzU4,6YhdV0BKWTh3M22uoHrEdeI_eUVZLHdlKYEtPFQ8P__WuSea3AFMDTBKDIzC2UNN2GnK4eVSnL54ZIUZDihddu9CI74my1jHESqjX7czgrXEHjDCIHFYymlYhBU\" style=\"border:0;padding:1px\" width=\"550\"/></a></div><h3 class=\"r\"><a href=\"/url?q=http://www.fs.usda.gov/malheur&sa=U&ei=tsCpU7y-HM28oQSa9IIQ&ved=0CBgQFjAA&usg=AFQjCNEd9QcHqk_lxZTz9AcslMsyLwA9XQ\"><b>Malheur National Forest</b> - Home - USDA Forest Service</a></h3><div class=\"s\"><div class=\"kv\" style=\"margin-bottom:2px\"><cite>www.fs.usda.gov/<b>malheur</b></cite><div class=\"am-dwn-arw-container\">‎<div aria-expanded=\"false\" aria-haspopup=\"true\" data-ved=\"0CBkQ7B0wAA\" onclick=\"google.sham(this);\" style=\"display:inline\" tabindex=\"0\"><span class=\"am-dwn-arw\"></span></div><div class=\"am-dropdown-menu\" role=\"menu\" style=\"display:none\" tabindex=\"-1\"><ul><li class=\"am-dropdown-menu-item\"><a class=\"am-dropdown-menu-item-text\" href=\"/url?q=http://webcache.googleusercontent.com/search%3Fq%3Dcache:0bqZkM4XQqIJ:http://www.fs.usda.gov/malheur%252BMalheur%2BNational%2BForest%26hl%3Den%26%26ct%3Dclnk&sa=U&ei=tsCpU7y-HM28oQSa9IIQ&ved=0CBsQIDAA&usg=AFQjCNHcxq8MhoHz9__jp8pwHUrw2RPqCQ\">Cached</a></li><li class=\"am-dropdown-menu-item\"><a class=\"am-dropdown-menu-item-text\" href=\"/search?ie=UTF-8&q=related:www.fs.usda.gov/malheur+Malheur+National+Forest&tbo=1&sa=X&ei=tsCpU7y-HM28oQSa9IIQ&ved=0CBwQHzAA\">Similar</a></li></ul></div></div></div><span class=\"st\">The 1.7 million acre <b>Malheur National</b> For est is located in the Blue Mountains of <br>\n"
"Eastern Oregon. The diverse and beautiful scenery of the <b>forest</b> includes high ...</br></span><br><div style=\"margin-top:13px\"><table width=\"100%\"><tr><td style=\"padding-right:4px;padding-top:1px\" valign=\"top\" width=\"24\"><img src=\"/mapfiles/marker-noalpha.png\"/></td><td valign=\"top\" width=\"485\"><span style=\"vertical-align:top\">Canyon City, OR 97820<br style=\"display:block\"><span class=\"nobr\">(541) 575-3000</span></br></span></td><td style=\"padding-top:2px;padding-left:9px\" valign=\"top\"><div style=\"float:right\"><div class=\"star\" style=\"float:none\"><div style=\"width:0px\"> </div></div></div><div style=\"clear:both\"><a class=\"fl nobr\" href=\"/url?q=https://plus.google.com/105110280666932757061/about%3Fhl%3Den%26socfid%3Dweb:lu:unknown:localdetails%26socpid%3D1&sa=U&ei=tsCpU7y-HM28oQSa9IIQ&ved=0CCAQ4gkwAA&usg=AFQjCNEo8ifBqVIqKICfCb2t4c6TZYk5mA\">2 reviews</a></div></td></tr></table></div></br></div><table cellpadding=\"0\" cellspacing=\"0\" class=\"slk\" style=\"border-collapse:collapse;margin-top:1px\"><tr class=\"mslg\"><td style=\"padding-left:23px;vertical-align:top\"><div class=\"sld\"><h3 class=\"r\"><a class=\"sla\" href=\"/url?q=http://www.fs.usda.gov/contactus/malheur/about-forest/contactus&sa=U&ei=tsCpU7y-HM28oQSa9IIQ&ved=0CCMQjBAwAQ&usg=AFQjCNGjoBzfmSfSTCOzBNxBnOhKa28FUQ\">Contact Us</a></h3><div class=\"s st\" style=\"width:220px;overflow:hidden\">More information is available on individual Ranger District Office ...</div></div></td><td style=\"padding-left:7px;vertical-align:top\"><div class=\"sld\"><h3 class=\"r\"><a class=\"sla\" href=\"/url?q=http://www.fs.usda.gov/recmain/malheur/recreation&sa=U&ei=tsCpU7y-HM28oQSa9IIQ&ved=0CCUQjBAwAw&usg=AFQjCNEmTooI03G5kMNTyIVqgU8Cu822dg\">Recreation</a></h3><div class=\"s st\" style=\"width:220px;overflow:hidden\">The 1.7 million acre Malheur National Forest located in the ...</div></div></td></tr><tr class=\"mslg\"><td style=\"padding-left:23px;vertical-align:top\"><div class=\"sld\"><h3 class=\"r\"><a class=\"sla\" href=\"/url?q=http://www.fs.usda.gov/main/malheur/maps-pubs&sa=U&ei=tsCpU7y-HM28oQSa9IIQ&ved=0CCcQjBAwAg&usg=AFQjCNFuRB8FTFH1goZ5XStBRakys6JoIQ\">Maps & Publications</a></h3><div class=\"s st\" style=\"width:220px;overflow:hidden\">Forest Service Topography Maps: These maps overlay Forest ...</div></div></td><td style=\"padding-left:7px;vertical-align:top\"><div class=\"sld\"><h3 class=\"r\"><a class=\"sla\" href=\"/url?q=http://www.fs.usda.gov/main/malheur/about-forest&sa=U&ei=tsCpU7y-HM28oQSa9IIQ&ved=0CCkQjBAwBA&usg=AFQjCNHSrG5pziXkX2tf50PdNo7qWMeT1A\">About the Forest</a></h3><div class=\"s st\" style=\"width:220px;overflow:hidden\">The Malheur National Forest in the Blue Mountains of Eastern ...</div></div></td></tr><tr><td colspan=\"2\" style=\"padding-left:28px;vertical-align:top\"><div style=\"padding-top:5px\"><a class=\"fl\" href=\"/search?ie=UTF-8&q=+site:usda.gov+Malheur+National+Forest&sa=X&ei=tsCpU7y-HM28oQSa9IIQ&ved=0CCoQrAM\">More results from usda.gov »</a></div></td></tr></table></li>")
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