# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r'ingredient-amount"\>(.+)\<\/span>'
test_str = "<div class=\"wprm-recipe-ingredients-container wprm-recipe-ingredients-no-images wprm-recipe-31141-ingredients-container wprm-block-text-normal wprm-ingredient-style-regular wprm-recipe-images-before\" data-recipe=\"31141\" data-servings=\"16\"><h3 class=\"wprm-recipe-header wprm-recipe-ingredients-header wprm-block-text-bold wprm-align-left wprm-header-decoration-none\" style=\"\">Ingredients</h3><div class=\"wprm-recipe-ingredient-group\"><h4 class=\"wprm-recipe-group-name wprm-recipe-ingredient-group-name wprm-block-text-bold\">For the dough:</h4><ul class=\"wprm-recipe-ingredients\"><li class=\"wprm-recipe-ingredient\" style=\"list-style-type: disc;\" data-uid=\"1\"><span class=\"wprm-recipe-ingredient-amount\">2/3</span> <span class=\"wprm-recipe-ingredient-unit\">cup</span> <span class=\"wprm-recipe-ingredient-name\">heavy cream</span> <span class=\"wprm-recipe-ingredient-notes wprm-recipe-ingredient-notes-faded\">(at room temperature)</span></li><li class=\"wprm-recipe-ingredient\" style=\"list-style-type: disc;\" data-uid=\"2\"><span class=\"wprm-recipe-ingredient-amount\">1</span> <span class=\"wprm-recipe-ingredient-unit\">cup</span> <span class=\"wprm-recipe-ingredient-name\">milk</span> <span class=\"wprm-recipe-ingredient-notes wprm-recipe-ingredient-notes-faded\">(whole milk preferred, but you can use 2%, at room temperature)</span></li><li class=\"wprm-recipe-ingredient\" style=\"list-style-type: disc;\" data-uid=\"3\"><span class=\"wprm-recipe-ingredient-amount\">1</span> <span class=\"wprm-recipe-ingredient-name\">large egg</span> <span class=\"wprm-recipe-ingredient-notes wprm-recipe-ingredient-notes-faded\">(at room temperature)</span></li><li class=\"wprm-recipe-ingredient\" style=\"list-style-type: disc;\" data-uid=\"4\"><span class=\"wprm-recipe-ingredient-amount\">1/3</span> <span class=\"wprm-recipe-ingredient-unit\">cup</span> <span class=\"wprm-recipe-ingredient-name\">sugar</span></li><li class=\"wprm-recipe-ingredient\" style=\"list-style-type: disc;\" data-uid=\"5\"><span class=\"wprm-recipe-ingredient-amount\">1/2</span> <span class=\"wprm-recipe-ingredient-unit\">cup</span> <span class=\"wprm-recipe-ingredient-name\">cake flour</span> <span class=\"wprm-recipe-ingredient-notes wprm-recipe-ingredient-notes-faded\">(can substitute 1/2 cup all purpose flour sifted with 1 tbsp cornstarch)</span></li><li class=\"wprm-recipe-ingredient\" style=\"list-style-type: disc;\" data-uid=\"6\"><span class=\"wprm-recipe-ingredient-amount\">3 1/2</span> <span class=\"wprm-recipe-ingredient-unit\">cups</span> <span class=\"wprm-recipe-ingredient-name\">bread flour</span> <span class=\"wprm-recipe-ingredient-notes wprm-recipe-ingredient-notes-faded\">(tap measuring cup to avoid air pockets)</span></li><li class=\"wprm-recipe-ingredient\" style=\"list-style-type: disc;\" data-uid=\"7\"><span class=\"wprm-recipe-ingredient-amount\">1</span> <span class=\"wprm-recipe-ingredient-unit\">tablespoon</span> <span class=\"wprm-recipe-ingredient-name\">active dry yeast</span> <span class=\"wprm-recipe-ingredient-notes wprm-recipe-ingredient-notes-faded\">(or instant yeast)</span></li><li class=\"wprm-recipe-ingredient\" style=\"list-style-type: disc;\" data-uid=\"8\"><span class=\"wprm-recipe-ingredient-amount\">1 1/2</span> <span class=\"wprm-recipe-ingredient-unit\">teaspoons</span> <span class=\"wprm-recipe-ingredient-name\"><a href=\"https://thewoksoflife.com/chinese-spices-condiments/#salt\" class=\"wprm-recipe-ingredient-link\" target=\"_blank\">salt</a></span></li></ul></div><div class=\"wprm-recipe-ingredient-group\"><h4 class=\"wprm-recipe-group-name wprm-recipe-ingredient-group-name wprm-block-text-bold\">For the filling:</h4><ul class=\"wprm-recipe-ingredients\"><li class=\"wprm-recipe-ingredient\" style=\"list-style-type: disc;\" data-uid=\"10\"><span class=\"wprm-recipe-ingredient-amount\">2</span> <span class=\"wprm-recipe-ingredient-unit\">tablespoons</span> <span class=\"wprm-recipe-ingredient-name\">vegetable oil</span></li><li class=\"wprm-recipe-ingredient\" style=\"list-style-type: disc;\" data-uid=\"11\"><span class=\"wprm-recipe-ingredient-amount\">1/2</span> <span class=\"wprm-recipe-ingredient-unit\">cup</span> <span class=\"wprm-recipe-ingredient-name\"><a href=\"https://thewoksoflife.com/chinese-chives-scallions-aromatics-peppers/#shallots\" class=\"wprm-recipe-ingredient-link\" target=\"_blank\">shallots</a></span> <span class=\"wprm-recipe-ingredient-notes wprm-recipe-ingredient-notes-faded\">(or onion, finely chopped)</span></li><li class=\"wprm-recipe-ingredient\" style=\"list-style-type: disc;\" data-uid=\"12\"><span class=\"wprm-recipe-ingredient-amount\">2</span> <span class=\"wprm-recipe-ingredient-unit\">tablespoons</span> <span class=\"wprm-recipe-ingredient-name\">granulated sugar</span></li><li class=\"wprm-recipe-ingredient\" style=\"list-style-type: disc;\" data-uid=\"13\"><span class=\"wprm-recipe-ingredient-amount\">2</span> <span class=\"wprm-recipe-ingredient-unit\">teaspoons</span> <span class=\"wprm-recipe-ingredient-name\"><a href=\"https://thewoksoflife.com/soy-sauce/\" class=\"wprm-recipe-ingredient-link\" target=\"_blank\">light soy sauce</a></span></li><li class=\"wprm-recipe-ingredient\" style=\"list-style-type: disc;\" data-uid=\"14\"><span class=\"wprm-recipe-ingredient-amount\">2</span> <span class=\"wprm-recipe-ingredient-unit\">tablespoons</span> <span class=\"wprm-recipe-ingredient-name\"><a href=\"https://thewoksoflife.com/oyster-sauce/\" class=\"wprm-recipe-ingredient-link\" target=\"_blank\">oyster sauce</a></span></li><li class=\"wprm-recipe-ingredient\" style=\"list-style-type: disc;\" data-uid=\"15\"><span class=\"wprm-recipe-ingredient-amount\">1 1/2</span> <span class=\"wprm-recipe-ingredient-unit\">teaspoons</span> <span class=\"wprm-recipe-ingredient-name\"><a href=\"https://thewoksoflife.com/sesame-oil/\" class=\"wprm-recipe-ingredient-link\" target=\"_blank\">sesame oil</a></span></li><li class=\"wprm-recipe-ingredient\" style=\"list-style-type: disc;\" data-uid=\"16\"><span class=\"wprm-recipe-ingredient-amount\">2</span> <span class=\"wprm-recipe-ingredient-unit\">teaspoons</span> <span class=\"wprm-recipe-ingredient-name\"><a href=\"https://thewoksoflife.com/dark-soy-sauce/\" class=\"wprm-recipe-ingredient-link\" target=\"_blank\">dark soy sauce</a></span></li><li class=\"wprm-recipe-ingredient\" style=\"list-style-type: disc;\" data-uid=\"17\"><span class=\"wprm-recipe-ingredient-amount\">¾</span> <span class=\"wprm-recipe-ingredient-unit\">cup</span> <span class=\"wprm-recipe-ingredient-name\"><a href=\"https://thewoksoflife.com/homemade-chicken-stock/\" class=\"wprm-recipe-ingredient-link\" target=\"_blank\">chicken stock</a></span></li><li class=\"wprm-recipe-ingredient\" style=\"list-style-type: disc;\" data-uid=\"18\"><span class=\"wprm-recipe-ingredient-amount\">2</span> <span class=\"wprm-recipe-ingredient-unit\">tablespoons</span> <span class=\"wprm-recipe-ingredient-name\">all purpose flour</span></li><li class=\"wprm-recipe-ingredient\" style=\"list-style-type: disc;\" data-uid=\"19\"><span class=\"wprm-recipe-ingredient-amount\">2</span> <span class=\"wprm-recipe-ingredient-unit\">cups</span> <span class=\"wprm-recipe-ingredient-name\"><a href=\"https://thewoksoflife.com/chinese-bbq-pork-cha-siu/\" class=\"wprm-recipe-ingredient-link\" target=\"_blank\">Chinese roast pork</a></span> <span class=\"wprm-recipe-ingredient-notes wprm-recipe-ingredient-notes-faded\">(<a href=\"https://thewoksoflife.com/2014/02/chinese-bbq-pork-cha-siu/\" target=\"_blank\">char siu</a>, finely diced)</span></li></ul></div><div class=\"wprm-recipe-ingredient-group\"><h4 class=\"wprm-recipe-group-name wprm-recipe-ingredient-group-name wprm-block-text-bold\">To finish the buns:</h4><ul class=\"wprm-recipe-ingredients\"><li class=\"wprm-recipe-ingredient\" style=\"list-style-type: disc;\" data-uid=\"21\"><span class=\"wprm-recipe-ingredient-name\">egg wash</span> <span class=\"wprm-recipe-ingredient-notes wprm-recipe-ingredient-notes-faded\">(1 egg, beaten with 1 tablespoon water) </span></li><li class=\"wprm-recipe-ingredient\" style=\"list-style-type: disc;\" data-uid=\"22\"><span class=\"wprm-recipe-ingredient-amount\">1</span> <span class=\"wprm-recipe-ingredient-unit\">tablespoon</span> <span class=\"wprm-recipe-ingredient-name\"><a href=\"https://thewoksoflife.com/sesame-seeds/\" class=\"wprm-recipe-ingredient-link\" target=\"_blank\">sesame seeds</a></span> <span class=\"wprm-recipe-ingredient-notes wprm-recipe-ingredient-notes-faded\">(optional)</span></li><li class=\"wprm-recipe-ingredient\" style=\"list-style-type: disc;\" data-uid=\"23\"><span class=\"wprm-recipe-ingredient-amount\">1</span> <span class=\"wprm-recipe-ingredient-unit\">tablespoon</span> <span class=\"wprm-recipe-ingredient-name\">granulated sugar</span> <span class=\"wprm-recipe-ingredient-notes wprm-recipe-ingredient-notes-faded\">(dissolved in 1 tablespoon boiling water)</span></li></ul></div><div class=\"wprm-unit-conversion-container wprm-unit-conversion-container-31141 wprm-unit-conversion-container-links wprm-block-text-normal\" data-recipe-unit-system=\"1\" style=\"\"><a href=\"#\" role=\"button\" class=\"wprm-unit-conversion wprmpuc-active\" data-system=\"1\" data-recipe=\"31141\" style=\"\" aria-label=\"Change unit system to US Customary\">US Customary</a> - <a href=\"#\" role=\"button\" class=\"wprm-unit-conversion\" data-system=\"2\" data-recipe=\"31141\" style=\"\" aria-label=\"Change unit system to Metric\">Metric</a></div></div>"
matches = re.finditer(regex, test_str, 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