fork download
  1. class Example
  2. {
  3. private static String regex = "^(?:VM|VF|TV|IM|IF)(?:;(?:VM|VF|TV|IM|IF))*$";
  4.  
  5. public static void main (String[] args) throws java.lang.Exception
  6. {
  7. test("VF;VM", true);
  8. test("VF;GM", false);
  9. test("VF,VM", false);
  10. test("VF;VM;IF", true);
  11. test("VF,VM;IF", false);
  12. }
  13.  
  14. private static void test(String str, boolean expectedResult) {
  15. boolean result = str.matches(regex);
  16. System.out.println(str + " -- " + (result ? "Good" : "Bad") + (result == expectedResult ? " - OK" : " - ERROR"));
  17. }
  18. }
Success #stdin #stdout #stderr 0.04s 711168KB
stdin
Standard input is empty
stdout
VF;VM -- Good - OK
VF;GM -- Bad - OK
VF,VM -- Bad - OK
VF;VM;IF -- Good - OK
VF,VM;IF -- Bad - OK
stderr
Java HotSpot(TM) Client VM warning: No monotonic clock was available - timed services may be adversely affected if the time-of-day clock changes