fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.util.regex.*;
  4.  
  5. class Main
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. Pattern p = Pattern.compile("[^.]+\\.(?!xml-test$).*");
  10. boolean ok1 = p.matcher("database123.xml").matches();
  11. boolean ok2 = p.matcher("database123.sql").matches();
  12. boolean ok3 = p.matcher("log_file012.txt").matches();
  13. boolean ok4 = p.matcher("database.xml-test").matches();
  14. boolean ok5 = p.matcher("database.xml-test.xml").matches();
  15. System.out.println(ok1);
  16. System.out.println(ok2);
  17. System.out.println(ok3);
  18. System.out.println(ok4);
  19. System.out.println(ok5);
  20. }
  21. }
Success #stdin #stdout 0.03s 245632KB
stdin
Standard input is empty
stdout
true
true
true
false
true