I have a code check if the user input is valid in the regular expression pattern. The patter is @ the problem is how to check if the character . appears consecutively
[a-z|A-Z|0-9|[.]{1}]+@[[a-z|A-Z|0-9]+ i've tried this patter so far.
System.out.print("Enter your Email: ");
String userInput = new Scanner(System.in).nextLine();
Pattern pat = Pattern.compile("[a-z|A-Z|0-9|[.]{1}]+@[a-z|A-Z|0-9]+");
Matcher mat = pat.matcher(userInput);
if(mat.matches()){
System.out.print("Valid");
}else{
System.out.print("Invalid");
}
}
}
if the input is een..123@asd123 I expect the output will Invalid but if the input is een.123@asd123 the output will Valid