import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "\\d\\d.-?.\\w.-?.\\d\\d";
final String string = "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen-533 Berkshire 5 min 27-Jun-18 14:27 9.0 --- --- 0.08\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen-533 Berkshire 27-Jun-18 9.0 18.9 7.7 ---\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen 247 Brock Street North 27-Jun-18 13.0 19 7.6 ---\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen 245 Brock St N 5min 09-Jul-18 14:35 9.0 --- --- 12.1\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen 245 Brock St N 09-Jul-18 9.0 7.5 22.4 ---\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen-665 Cherry Dr 5min 21-Jun-18 11:04 8.0 --- 3.93\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen-665 Cherry Dr 21-Jun-18 8.0 7.7 ---\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen 1390 Christina Street North 10-Oct-18 16.0 7.6 ---\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen 140 Conrad St 09-Jul-18 9.0 7.6 21.6 ---\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen 763 Copland 27-Jun-18 13.0 19.3 7.6 ---\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen-560 Cromwell St 5th 09-May-18 13:37 12.0 --- 16.1\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen-560 Cromwell St 09-May-18 12.0 7.0 ---\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen 534 Davis Street 5min 30-Aug-18 14:34 17.0 --- 9.05\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen 534 Davis Street 30-Aug-18 --- 7.5 ---\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen-534 Devine St 5min 25-Jun-18 08:04 10.0 --- --- 0.05\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen-534 Devine St 25-Jun-18 10.0 6.6 18.4 ---\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen 845 Devine St-5 Min 26-Jun-18 12:43 8.0 --- --- 75 0.17\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen 845 Devine St 26-Jun-18 8.0 18.5 7.6 --- ---\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen 357 East St-5 26-Sep-18 09:04 19.0 --- 0.09\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen 357 East St 19.0 7.8 ---\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen 357 East St-1 26-Sep-18 09:34 19.0 --- 0.27\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : NR Kitchen 357 East St-2 26-Sep-18 09:34 19.0 --- 0.14\n"
+ "root - ERROR - : 06/05/2019, 14:29:55 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen 306 Elgin St 10-Oct-18 16.0 8.0 ---\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen 308 Elgin St-1 26-Sep-18 11:32 19.0 --- 6.47\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-641 Elm Ave 09-May-18 12.0 6.7 ---\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-267 Emma St 29-May-18 11.0 7.8 ---\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-272 Emma St 24-May-18 11.0 7.3 ---\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-278 Emma St 29-May-18 11.0 7.4 ---\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-297 Emma St 24-May-18 11.0 7.3 ---\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-301 Emma 24-May-18 11.0 7.2 ---\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-248 Emma St 08-May-18 16.0 7.4 ---\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-257 Emma St 5th 08-May-18 12:30 16.0 --- 1.21\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-263 Emma St 07-May-18 16.0 7.8 ---\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-273 Emma St 07-May-18 12:41 16.0 7.7 ---\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-277 Emma St 08-May-18 16.0 7.8 ---\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-281 Emma St 07-May-18 13:48 16.0 7.9 ---\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-284 Emma St 08-May-18 16.0 7.8 ---\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-291 Emma St 07-May-18 14:30 16.0 7.8 ---\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-299 Emma St 08-May-18 16.0 7.6 ---\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-300 Emma St 08-May-18 16.0 7.9 ---\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-247 Emma St 09-May-18 12.0 7.9 ---\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-288 Emma St 10-May-18 12.0 7.8 ---\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:56 : NR Kitchen-303 Emma St 10-May-18 12.0 7.6 ---\n"
+ "root - ERROR - : 06/05/2019, 14:29:57 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:57 : NR Kitchen 320 Exmouth 12-Jul-18 8.0 21.9 7.6 ---\n"
+ "root - ERROR - : 06/05/2019, 14:29:57 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:57 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:57 : NR Kitchen 571 Flamingo DR 5 03-Oct-18 09:16 Curtis Salisbury 16.0 --- 0.07\n"
+ "root - ERROR - : 06/05/2019, 14:29:57 : NR Kitchen 571 Flamingo DR 03-Oct-18 Curtis Salisbury 16.0 7.9 ---\n"
+ "root - ERROR - : 06/05/2019, 14:29:57 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:57 : NR Kitchen 590 Flamingo 5min 14-Aug-18 15:04 12.0 --- --- 0.08\n"
+ "root - ERROR - : 06/05/2019, 14:29:57 : NR Kitchen 590 Flamingo 14-Aug-18 12.0 7.6 22.3 ---\n"
+ "root - ERROR - : 06/05/2019, 14:29:57 : -NR\n"
+ "root - ERROR - : 06/05/2019, 14:29:57 : NR Kitchen 122 Forsyth North 31-Jul-18 Curtis Salisbury 12.0 21.6 7.4 ---\n"
+ "root - ERROR - : 06/05/2019, 14:29:57 : -NR\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