import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "(^.*?((?:[A-Za-z]+_)+[A-Z]\\w+)(?:-([0-9]{8}-[0-9]{6})-([0-9]{8}-[0-9]{6}))?)";
final String string = "mixexecutor:check_atom_exists:740 - requested to check this machine : ET_colBackDDW_Temp \n\n"
+ "output_of_reports/PII/36478_ABP_BAL_liquidpressure-20210831-123456-20210831-172355.bat.yz\n\n"
+ "packofexecutors:_to_signle_que:869-no mata for file'/private/external_control_time_mapped_low_volume/IBA/54378_BD-RT_69-1-1-20200831-152355-20200831-172355.dat.xz'\n\n"
+ "packofexecutors:_to_signle_que:869-no mata for file'/private/external_control_time_mapped_low_volume/IBA/54378_BD-RT_69-1-20200831-152355-20200831-172355.dat.xz'\n\n"
+ "mixexecutor:check_atom_exists:740 - requested to check this machine : Eanes_colBack12_current\n\n"
+ "packofexecutors._check_tar.587-nr of missed files=78 nr of skipped records=6547 nr of records not exist=0\n\n"
+ "packofexecutors._filter_mistacl_signals:777 - invalid atomname for RT_6:ESmotormeaninfAmkl";
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