import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "(?m)(?:^recipeingredient:\\s\\[\\\".*|\\G)[^\\\"]*\\K\\\\";
final String string = "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:";
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