# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"(?m)(?:^recipeingredient:\s\[\".*|\G)[^\"]*\K\\"
test_str = ("description: \"Easiest Way to Prepare Speedy Dal Chicken\"\n"
"title: \"How to Prepare Award-winning Dal Chicken\"\n"
"date: 2020-12-10T07:38:14.079Z\n"
"image: https://img-\\global.cpcdn.com/recipes/f92bd4e2e07d9fa1/751x532cq70/dal-chicken-recipe-main-photo.jpg\n"
"thumbnail: https://img-global.cpcdn.com/recipes/f92bd4e2e07d9fa1/751x532cq70/dal-chicken-recipe-main-photo.jpg\n"
"cover: https://img-global.cpcdn.com/recipes/f92bd4e2e07d9fa1/751x532cq70/dal-chicken-recipe-main-photo.jpg\n"
"author: Mathilda Day\n"
"ratingvalue: 4.9\n"
"reviewcount: 44224\n"
"recipeingredient: [\"1 chicken breast - cut in small pieces\",\"1 \\ 1/2 cup chana dal - soaked over night and partially boiled\",\"1 tblsp red chilli powder\",\"1 tblsp dhaniya powder\",\"pinch turmeric powder\",\"1 1/2 tblsp of ginger-garlic paste\",\" Salt per taste\",\"3 black peppers (whole)\",\"3,4 cloves\",\"1 cinnamon stick\",\"1/2 tsp cumin seeds\",\"1 medium onion - finely chopped\",\"1 medium tomato paste\",\"4 tblsp oil\",\"as needed Water\",]\n"
"recipeinstructions: [\"Heat oil in a wok - Add cumin seeds, black peppers, cloves, and cinnamon stick.\",\"Add onions.Let it cook till it turns light brownAdd tomato paste.Let it cook till oil separates.\",\"Add lal masala (Step 3) & salt - Cook till oil separates and the masala is cooked.Add chicken and chana dal.Add water as needed.\",\"Cook till chicken and the dal has properly cooked and the gravy is at the consistency that you want.\",\"Serve with roti aur chapati.\",]\n"
"categories:")
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