fork(2) download
  1. import java.util.*;
  2. import java.lang.*;
  3.  
  4. class Main
  5. {
  6. public static void main (String[] args) throws java.lang.Exception
  7. {
  8. String regex = "^[\u0400-\u04FFa-zA-Z ]+(,[\u0400-\u04FFa-zA-Z ]+)*$";
  9.  
  10. System.out.println("abc,xyz,pqr".matches(regex)); // true
  11. System.out.println("text1,text2,".matches(regex)); // false
  12. System.out.println("ЕЖЗ,ИЙК".matches(regex)); // true
  13. }
  14. }
Success #stdin #stdout 0.06s 380224KB
stdin
Standard input is empty
stdout
true
false
true