I have something like the below line of String.
String log = "Daily batch run has been completed Status = Success at the first attempt Logging out Admin...OK"
String batchOutput = "";
I need to extract only "Success at the first attempt".
I have tried out the below.
Pattern pattern = Pattern.compile("Status = (.*)");
Matcher matcher = pattern.match(log);
if (matcher.find()) {
batchOutput = matcher.group(1);
System.out.println(batchOutput) // This displays Status = Success at the first attempt Logging out Admin...OK"
}
However, I need to extract out only "Status = Success at the first attempt"
Again I took a substring of the batchOutput string
batchOutput = batchOutput.substring(0, batchOutput.indexOf("L")).trim(); // This displays only "Status = Success at the first attempt"
I believe that instead of using the substring method, this can be extracted out by using valid regex expression.
Could I get some help on this please? }