# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"\[.*?\)"
test_str = "Steps:\\n\\n[Step as , asdasd . sd32 'd](http://dev.nzfood-site.wn.bauer-media.net.au/silver-fern-farms-competition-21001) 1 Preheat oven to 120°C. Arrange six 1 1/2-cup ramekins in large baking dish lined [with](http://dev.nzfood-site.wn.bauer-media.net.au/silver-fern-farms-competition-21001) a cloth. \\nStep 2 In a medium saucepan, combine cream and vanilla. Place over medium heat and bring to almost boiling point. \\nStep 3 Meanwhile, in a bowl, whisk yolks and sugar together until thick and pale. Gradually pour in hot cream mixture, whisking constantly. \\nStep 4 Return mixture to clean saucepan. Cook on low heat 10-12 minutes, stirring constantly until thick enough to just coat the back of a wooden spoon (be careful not to overheat or mixture will curdle). \\nStep 5 Divide custard between ramekins. Pour boiling water into baking dish to come halfway up sides of ramekins. Bake 20-25 minutes until almost set and slightly wobbly in centre. Remove ramekins. \\nStep 6 Cool completely in fridge. Just before serving, sprinkle custards with an even layer of raw sugar. Using a kitchen blowtorch, drag the flame back and forth over the sugar until caramelised."
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