// My Scanner
Scanner input = new Scanner(System.in);
//using Do While Loop
do {
//Asking user to enter email
System.out.println("enter your email:");
//Read and safe input in to Var userEmail
String userEmail = input.next();
//Check for contains '@' and '.com' simbols
Pattern pattern = Pattern.compile("\\[email protected]\\S+?\\.com");
//And it checking in users entered email
Matcher matcher = pattern.matcher(userEmail);
//if userEmail contain '@'and '.com' print next line
if (matcher.matches()) {
System.out.println("Matches"); // Prints this for this email
}
//if user put email with out '@'and'.com' print next line
else {
System.out.println("your email should
looks like this sample [email protected]");
}
// And here I have a problem don't know what to type in
// so that it starts looping until user input will be 100% correct.
} while(!matcher.matches());
有人可以帮助什么需要在这里做while(here);
使其循环?验证电子邮件地址后,如何在循环中做到这一点?
那么,呃,所有'Blockquote's是什么意思? – Ross
对不起,只是误点了他们 –