我想像这样设计字符串:
letters (in here there may be letters, numbers and whitespace)
我已经尝试过,但它不起作用。
Scanner cin = new Scanner(System.in);
String format = "^[a-zA-Z]* ([a-zA-Z_0-9\\s]*)$";
String userInput = cin.nextLine();
if (userInput.matches(format)) {
System.out.println("Correct Patten");
} else {
System.out.println("Incorrect Pattern");
}
提前致谢...