import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "'name': '(.*?)', 'awardedAt': (-?\\d+),";
final String string = "[{'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";
final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
final Matcher matcher = pattern.matcher(string);
while (matcher.find()) {
System.out.println("Full match: " + matcher.group(0));
for (int i = 1; i <= matcher.groupCount(); i++) {
System.out.println("Group " + i + ": " + matcher.group(i));
}
}
}
}
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 Java, please visit: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html