I am new here and I have a problem with a code.
I have a String of 5 characters, and this is what I've come up with
public static boolean isNumber(String strng) {
return (strng.contains("[0-9]+"));
}
public static void main(String[] args) {
String strng;
Scanner strong = new Scanner(System.in);
while (isNumber(dato) == true && dato.length() != 5){
System.out.println("Isnt a correct id number");
strng = strong.nextLine();
}
But with this I can introduce a dot or a semi-colon, I tried with [a-zA-Z]+
and the boolean
in false but isn't work I'm searching only for numbers from 0 to 9.
Any clue for this?