fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  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. System.out.println(checkConstraint("sec 30-31"));
  13. }
  14. private static boolean checkConstraint(String inputValue) {
  15. inputValue = inputValue.trim();
  16. if (inputValue.matches("[\\>][\\s]*[\\d]*") || inputValue.matches("[\\<][\\s]*[\\d]*") || inputValue.matches("[\\d]*[\\s]*[-][\\s]*[\\d]*")
  17. || inputValue.matches("[\\=][\\s]*[\\d]*") || inputValue.matches("[\\=][\\s]*[\\w]*") || inputValue.matches("[\\d]*")
  18. || inputValue.matches("[\\w]*") || inputValue.matches("[\\d]*[\\s]*[|][\\s]*[\\d]*")
  19. || inputValue.matches("[\\w]*[\\s]*[|][\\s]*[\\w]*") || inputValue.matches("[\\d]*[\\,][[\\s]*\\d\\,]*")
  20. || inputValue.matches("[\\w]*[\\,][[\\s]*\\w\\,]*") || inputValue.matches("[\\d]*[\\s]*[\\?]")
  21. || inputValue.matches("[\\w]*[\\s]*[\\?]") || inputValue.matches("[\\d]*[\\s]*[\\*]") || inputValue.matches("[\\w]*[\\s]*[\\*]")
  22. || inputValue.matches("[\\w]*[\\s]*[\\w\\,]*") || inputValue.matches("[\\s]*[\\%]*[\\s]*[\\w]*[\\s]*")
  23. || inputValue.matches("[\\s]*[\\w]*[\\s]*[\\%][\\s]*") || inputValue.matches("[\\s]*[\\%]*[\\s]*[\\w]*[\\s]*[\\%][\\s]*")
  24. || inputValue.matches("[\\w]*[\\s]*[-][\\s]*[\\w]*") || inputValue.matches("[\\w]*[\\s]*[.][\\s]*[\\w]*")
  25. || inputValue.matches("[\\w]*[\\s]*['][\\s]*[\\w]*") || inputValue.matches("[[\\w]*[\\s]*[\\w]*[\\s]*]*") || inputValue.matches("[a-zA-Z]+\\s+\\d+-\\d+")) {
  26. return true;
  27. }
  28. return false;
  29. }
  30. }
Success #stdin #stdout 0.13s 320576KB
stdin
Standard input is empty
stdout
true