Hello I am developing a word game where i want to check the user input as valid word or not please suggest the way i can check the given string in android.
Eg . Str
You can try this code for basic validation
import java.util.Scanner;
public class InputValidation {
public static void main(String[] args) {
String input;
try {
System.out.println("Enter the input");
Scanner s = new Scanner(System.in);
input = s.next();
if(input.matches(".*\\d.*")){
System.out.println(" Contains digit only");
} else{
System.out.println(" Only String/words found");
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}