fork download
  1. import java.util.regex.Matcher;
  2. import java.util.regex.Pattern;
  3.  
  4. class Main
  5. {
  6. public static void main (String[] args) throws java.lang.Exception
  7. {
  8. String str = "a;b\nc;d;e;f;g\nc;d;e;f;g\nc;d;e;f;g\n\na;b\nc;d;e;f;g\nc;d;e;f;g\nc;d;e;f;g\n\na;b\n\na;b\nc;d;e;f;g\nc;d;e;f;g\nc;d;e;f;g";
  9. Pattern p = Pattern.compile("(?m)^(?:.+(?:\\r?\\n|\\Z)){2,}");
  10. Matcher m = p.matcher(str);
  11. while (m.find()) {
  12. String match = m.group();
  13. System.out.println(match);
  14. }
  15. }
  16. }
Success #stdin #stdout 0.03s 245632KB
stdin
Standard input is empty
stdout
a;b
c;d;e;f;g
c;d;e;f;g
c;d;e;f;g

a;b
c;d;e;f;g
c;d;e;f;g
c;d;e;f;g

a;b
c;d;e;f;g
c;d;e;f;g
c;d;e;f;g