# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"'name': '(.*?)', 'awardedAt': (-?\d+),"
test_str = ("[{'name': 'Locus Award', 'awardedAt': 1230796800000, 'category': 'Best Young Adult Book', 'hasWon': None}, {'name': 'Georgia Peach Book Award', 'awardedAt': 1230796800000, 'category': '', 'hasWon': None}, {'name': 'Buxtehuder Bulle', 'awardedAt': 1230796800000, 'category': None, 'hasWon': None}, {'name': 'Golden Duck Award', 'awardedAt': 1230796800000, 'category': 'Young Adult (Hal Clement Award)', 'hasWon': None}, {'name': \"Grand Prix de l'Imaginaire\", 'awardedAt': 1262332800000, 'category': 'Roman jeunesse étranger', 'hasWon': None}, {'name': 'Books I Loved Best Yearly (BILBY) Awards', 'awardedAt': 1325404800000, 'category': 'Older Readers', 'hasWon': None}, {'name': \"West Australian Young Readers' Book Award (WAYRBA)\", 'awardedAt': 1262332800000, 'category': 'Older Readers', 'hasWon': None}, {'name': \"Red House Children's Book Award\", 'awardedAt': 1262332800000, 'category': 'Older Readers & Overall', 'hasWon': None}, {'name': 'South Carolina Book Award', 'awardedAt': 1293868800000, 'category': 'Junior and Young Adult Book', 'hasWon': None}, {'name': 'Charlotte Award', 'awardedAt': 1262332800000, 'category': None, 'hasWon': None}, {'name': 'Colorado Blue Spruce Young Adult Book Award', 'awardedAt': 1262332800000, 'category': None, 'hasWon': None}, {'name': 'Teen Buckeye Book Award', 'awardedAt': 1230796800000, 'category': None, 'hasWon': None}, {'name': \"Pennsylvania Young Readers' Choice Award\", 'awardedAt': 1262332800000, 'category': 'Young Adults', 'hasWon': None}, {'name': 'Rhode Island Teen Book Award', 'awardedAt': 1262332800000, 'category': None, 'hasWon': None}, {'name': 'Vermont Golden Dome Book Award', 'awardedAt': 1262332800000, 'category': None, 'hasWon': None}, {'name': 'Evergreen Teen Book Award', 'awardedAt': 1293868800000, 'category': None, 'hasWon': None}, {'name': 'Soaring Eagle Book Award', 'awardedAt': 1230796800000, 'category': None, 'hasWon': None}, {'name': 'Milwaukee County Teen Book Award', 'awardedAt': 1262332800000, 'category': '', 'hasWon': None}, {'name': 'Sakura Medal', 'awardedAt': 1262332800000, 'category': 'Middle School Book', 'hasWon': None}, {'name': 'Michigan Library Association Thumbs Up! Award', 'awardedAt': 1230796800000, 'category': None, 'hasWon': None}, {'name': 'Florida Teens Read', 'awardedAt': 1230796800000, 'category': None, 'hasWon': None}, {'name': 'Deutscher Jugendliteraturpreis', 'awardedAt': 1262332800000, 'category': 'Preis der Jugendjury', 'hasWon': None}, {'name': 'Iowa High School Book Award', 'awardedAt': 1293868800000, 'category': '', 'hasWon': None}, {'name': 'New Mexico Land of Enchantment Award', 'awardedAt': 1293868800000, 'category': 'Young Adult', 'hasWon': None}, {'name': 'Eliot Rosewater Indiana High School Book Award', 'awardedAt': 1262332800000, 'category': None, 'hasWon': None}, {'name': 'The Inky Awards', 'awardedAt': 1230796800000, 'category': 'Silver Inky', 'hasWon': None}, {'name': 'California Young Readers Medal', 'awardedAt': 1293868800000, 'category': 'Young Adult', 'hasWon': None}, {'name': 'Lincoln Award', 'awardedAt': 1293868800000, 'category': '', 'hasWon': None}, {'name': 'Kinderboekwinkelprijs', 'awardedAt': 1262332800000, 'category': '', 'hasWon': None}, {'name': 'Truman Readers Award', 'awardedAt': 1293868800000, 'category': None, 'hasWon': None}, {'name': 'CYBILS Award', 'awardedAt': 1199174400000, 'category': 'Young Adult Fantasy & Science Fiction', 'hasWon': None}, {'name': 'Literaturpreis der Jury der jungen Leser', 'awardedAt': 1262332800000, 'category': 'Jugendbuch', 'hasWon': None}, {'name': 'The Inky Awards Shortlist', 'awardedAt': 1230796800000, 'category': 'Silver Inky', 'hasWon': None}, {'name': 'Prix Et-lisez-moi', 'awardedAt': 1293868800000, 'category': None, 'hasWon': None}, {'name': 'Gateway Readers Award', 'awardedAt': 1293868800000, 'category': None, 'hasWon': None}, {'name': 'Oklahoma Sequoyah Award', 'awardedAt': 1293868800000, 'category': 'High School and Intermediate', 'hasWon': None}, {'name': 'Premio El Templo de las Mil Puertas', 'awardedAt': 1230796800000, 'category': 'Mejor novela extranjera perteneciente a saga', 'hasWon': None}, {'name': \"Rebecca Caudill Young Readers' Book Award\", 'awardedAt': 1293868800000, 'category': None, 'hasWon': None}, {'name': 'LovelyBooks Leserpreis', 'awardedAt': 1230796800000, 'category': 'Fantasy', 'hasWon': None}, {'name': 'LovelyBooks Leserpreis for Bestes Cover/Umschlag', 'awardedAt': 1230796800000, 'category': None, 'hasWon': None}, {'name': 'Premi Protagonista Jove', 'awardedAt': 1230796800000, 'category': 'Categoria 12-14 anys', 'hasWon': None}]\n")
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