import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "((?<=time:.).*?(?=;))|((?<=A:.).*?(?=;))|((?<=B:.\\().*?(?=\\)))|((?<=C:.\\().*?(?=\\)))|((?<=D\\().*?(?=\\)))|((?<=E:.\\().*?(?=\\)))";
final String string = "time: 2017-12-24 13:13:34 +0000; A: 61792; B: (\n"
+ "60328,\n"
+ "60344,\n"
+ "60344,\n"
+ "60344\n"
+ "); C: (\n"
+ "\"-3672\",\n"
+ "\"-3656\",\n"
+ "1547,\n"
+ "1578\n"
+ "); D(\n"
+ "1500,\n"
+ "1484,\n"
+ "1500,\n"
+ "); E: (\n"
+ "313,\n"
+ "328\n"
+ ")\n"
+ "time: 2017-12-25 13:13:35 +0000; A: 6134; B: (\n"
+ "628,\n"
+ "60374,\n"
+ "6044\n"
+ "); C: (\n"
+ "\"-72\",\n"
+ "\"6\",\n"
+ "157,\n"
+ "157\n"
+ "); D(\n"
+ "1700,\n"
+ "1654,\n"
+ "1580,\n"
+ "); E: (\n"
+ "3103,\n"
+ "3208\n"
+ ")";
final Pattern pattern = Pattern.compile(regex, Pattern.DOTALL);
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