fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.util.regex.*;
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. int width = 10, height = 5;
  13. String regex = "@(\\d+)\\R([01]{"+width+"}\\R??){"+height+"}";
  14. String text = "@200\r\n" +
  15. "0000000000\r\n" +
  16. "0000011001\r\n" +
  17. "1100100000\r\n" +
  18. "0101001101\r\n" +
  19. "1110001110\r\n" +
  20. "\r\n" +
  21. "@500\r\n" +
  22. "0000000000\r\n" +
  23. "0000011001\r\n" +
  24. "1100100000\r\n" +
  25. "0101001101\r\n" +
  26. "1110001110\r\n" +
  27. "";
  28. Pattern p = Pattern.compile(regex);
  29. Matcher m = p.matcher(text);
  30. while(m.find()){
  31. System.out.println(m.group());
  32. System.out.println("----------");
  33. }
  34. }
  35. }
Success #stdin #stdout 0.04s 711168KB
stdin
Standard input is empty
stdout
@200
0000000000
0000011001
1100100000
0101001101
1110001110
----------
@500
0000000000
0000011001
1100100000
0101001101
1110001110
----------