I want to find the amount of lines the appropiate regex matches. The input is a log file which in inserted via Java Stream. I want to apply multiple filter on this stream but count each seppretly.
Stream<String> lines = Files.lines(path);
// regex transformation to predicate for filter method
String[] regs = {".*/e_miete_1\\.html.*", ".*/fa-portal/(.*\\.html|api/.*).*"};
ArrayList<Predicate<String>> compRegs = new ArrayList<>();
for(String reg : regs) {
compRegs.add(Pattern.compile(reg).asPredicate());
}
// usage of predicate
eMiete = lines
.filter(compRegs.get(0))
.count();
clicks = lines
.filter(compRegs.get(1))
.count();
System.out.println(eMiete);
System.out.println(clicks);