fork download
  1. class Main{
  2. public static void main(String[] a){
  3. for(String testCase : new String[]{"abc", "ABC", "aB-c", "z", "-", "ÄBÇ", "", "123", "ABC0"})
  4. System.out.println('"'+testCase+"\": " + testCase.matches("^[a-zA-Z\\-]+$"));
  5. }
  6. }
Success #stdin #stdout 0.15s 36568KB
stdin
Standard input is empty
stdout
"abc": true
"ABC": true
"aB-c": true
"z": true
"-": true
"ÄBÇ": false
"": false
"123": false
"ABC0": false