fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.util.regex.*;
  5. import java.lang.*;
  6. import java.io.*;
  7.  
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. class Ideone
  10. {
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13. Pattern p = Pattern.compile("(.*)_(0?\\d|1[0-7])\\.png");
  14. for (int i = 0 ; i != 10 ; i++) {
  15. String s = "hello_0"+i+".png";
  16. Matcher m = p.matcher(s);
  17. System.out.println(s+":"+m.find());
  18. }
  19. for (int i = 0 ; i != 20 ; i++) {
  20. String s = "hello_"+i+".png";
  21. Matcher m = p.matcher(s);
  22. System.out.println(s+":"+m.find());
  23. }
  24. }
  25. }
Success #stdin #stdout 0.08s 380160KB
stdin
Standard input is empty
stdout
hello_00.png:true
hello_01.png:true
hello_02.png:true
hello_03.png:true
hello_04.png:true
hello_05.png:true
hello_06.png:true
hello_07.png:true
hello_08.png:true
hello_09.png:true
hello_0.png:true
hello_1.png:true
hello_2.png:true
hello_3.png:true
hello_4.png:true
hello_5.png:true
hello_6.png:true
hello_7.png:true
hello_8.png:true
hello_9.png:true
hello_10.png:true
hello_11.png:true
hello_12.png:true
hello_13.png:true
hello_14.png:true
hello_15.png:true
hello_16.png:true
hello_17.png:true
hello_18.png:false
hello_19.png:false