code: public static ArrayList<String> findStages(final ArrayList<String> lines, final String[] stageIndicators) {
      final ArrayList<String> stages = new ArrayList<>();
  
      int i = 0;
      for (final String line: lines) {
        if (line.contains(stageIndicators[i])){
          stages.add(stageIndicators[i]);
          if (i < stageIndicators.length - 1) {
            i++;
          }
        }
      }
      return stages;
    }
docs: find lines that contain stage indicators. The stageIndicators must be in sequence which appear in the lines.
  @param lines
  @param stageIndicators
  @return