import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "(?<event>^.\\S*[^\\n<]*(?:(?:<(?!)|\\n(?!$))[^\\n]*)*(?:|\\n$|\\z))";
final String string = "isDraggingObject : True\n"
+ "id : afbbdeb7-9fd4-4b53-ab17-742809154ba9\n"
+ "condition : {or, matches System.Object[] (?i)(^.*?host failure \n"
+ " alert.*?www\\.jennycraig\\.com\\.au.*?$), matches System.Object[] \n"
+ " (?i)(^.*?\\bwarning\\b.*?www\\.jennycraig\\.com\\.au.*?$)}\n"
+ "catch_all : False\n"
+ "advanced_condition : {}\n"
+ "actions : {route PVG22KK, severity warning}\n\n"
+ "isDraggingObject : True\n"
+ "id : 3b5aa785-b854-4e43-900a-225da5786a27\n"
+ "condition : {or, matches System.Object[] \n"
+ " (?i)(^.*?\\bcritical\\b.*?www\\.jennycraig\\.com\\.au.*?$)}\n"
+ "catch_all : False\n"
+ "advanced_condition : {}\n"
+ "actions : {severity critical, route PVG22KK}\n\n"
+ "**isDraggingObject : True\n"
+ "id : a8420998-fbca-486b-9ff7-d03b9e16536e\n"
+ "condition : {or, matches System.Object[] (?i)(^.*?\\bcritical\\b.*?www\\.jennycraig\\.com$), \n"
+ " matches System.Object[] (?i)(^.*?\\bcritical\\b.*?locations\\.jennycraig\\.com)}\n"
+ "catch_all : False\n"
+ "advanced_condition : {}\n"
+ "actions : {severity critical, route PW0VV83}**";
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