# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"([a-z\-_0-9\/\:\.]*\.(jpg|jpeg|png|gif))"
test_str = ("<a style=\"display:block;\" href=\"javascript:void(0);\" onclick=\"expandImageRotate ( 'xImage_56362441','http://snpi.dell.com/snp/images/products/large/en-th~370-ACMK/370-ACMK.jpg',event,this,'' );\"><img id=\"xImage_56362441_sm_Image\" border=\"0\" alt=\"Dell 8 GB Certified Replacement Memory Module for Select Dell Systems- UDIMM ECC\" title=\"Dell 8 GB Certified Replacement Memory Module for Select Dell Systems- UDIMM ECC\" width=\"200\" src=\"http://snpi.dell.com/snp/images/products/mlrg/en-th~370-ACMK/370-ACMK.jpg\" z></a>\n"
"</span></td></tr>\n"
"<tr><td colspan=\"2\" style=\"padding: 15px 0px 5px 0px\"><table cellpadding=\"4\" cellspacing=\"0\" align=\"center\" border=\"0\"><tr class=\"thumbnailRow\"><td align=\"center\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n"
"<tr>\n"
"<td><img src=\"http://i.dell.com/images/global/brand/ui/top_left_small.gif\" width=\"3\" height=\"3\"></td>\n"
"<td width=\"100%\"><img src=\"http://i.dell.com/images/global/brand/ui/top_horiz_small.gif\" width=\"100%\" height=\"3\" border=\"0\"></td>\n"
"<td class=\"rightAlign\"><img src=\"http://i.dell.com/images/global/brand/ui/top_right_small.gif\" width=\"3\" height=\"3\"></td>\n"
"</tr>\n"
"<tr>\n"
"<td class=\"leftVertSmall\"></td>\n"
"<td><span style=\"display:inline-block;width:40px;\">\n"
"<script type=\"text/javascript\">\n"
"RegisterImage('original_image', 'http://snpi.dell.com/snp/images/products/mlrg/en-th~370-ACMK/370-ACMK.jpg', 'http://snpi.dell.com/snp/images/products/large/en-th~370-ACMK/370-ACMK.jpg', \"Dell 8 GB Certified Replacement Memory Module for Select Dell Systems- UDIMM ECC\", 'xImage_18637405', '');\n"
"</script><div style=\"position: absolute; top: 0pt; left: 0pt;\" id=\"xImage_18637405_container\"></div>")
matches = re.search(regex, test_str, re.IGNORECASE)
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