public class Test {
public static void Main (string[] args) {
Email
String check = "^ ([a-z0-9a-z]+[-|\\.]?) +[a-z0-9a-z]@ ([a-z0-9a-z]+ (-[a-z0-9a-z]+) \ \.) +[a-za-z]{2,}$ ";
Pattern regex = pattern.compile (check);
Matcher Matcher = Regex.matcher ("[email protected]");
Boolean ismatched = Matcher.matches ();
System.out.println (ismatched);
}
public static void Main (string[] args) {
Scanner scanner=new Scanner (system.in);
String Mail=null;
System.out.println ("Please enter e-mail:");
Mail=scanner.next ();
Pattern pattern=pattern.compile ("\\[email protected" (\\w+.) +[a-z]{2,3} ");//\w represents a-z,a-z,0-9 (\ \ Escape character)
Matcher matcher=pattern.matcher (mail);
Boolean b=matcher.matches ();
if (b) {
SYSTEM.OUT.PRINTLN (mail+ "Valid email address! ");
}else {
SYSTEM.OUT.PRINTLN (mail+ "Format Error!! ");
}
}
/**
Verification of legality of *javascript e-mail
*/
function Isemail (email)
{
var srt=/^\w+ ((-\w+) | ( \.\w+)) *\@[a-za-z0-9]+ ((\.| -) [a-za-z0-9]+] *\. [a-za-z0-9]+$/;
if (srt.test (email))
{
When it's not legal
return false;
}
Else
{
Legal time
return true;
}
}
}
public static Boolean validateemail (String email) {
Boolean flag = false;
int pos = Email.indexof ("@");
if (pos = =-1 | | pos = = 0 | | pos = = email.length ()-1) {
return false;
}
String[] strings = Email.split ("@");
if (strings.length! = 2) {//If the mailbox is not in [email protected] Format
return false;
}
Charsequence cs = strings[0];
for (int i = 0; i < cs.length (); i++) {
char C = Cs.charat (i);
if (! Character.isletter (c) &&! Character.isdigit (c)) {
return false;
}
}
pos = Strings[1].indexof ("."); /If there is no after @, then it is the wrong mailbox.
if (pos = =-1 | | pos = = 0 | | pos = = email.length ()-1) {
return false;
}
strings = Strings[1].split (".");
for (int j = 0; J < Strings.length; J + +) {
cs = Strings[j];
if (cs.length () = = 0) {
return false;
}
for (int i = 0; i < cs.length (); i++) {//If an irregular character is protected, it indicates an error
char C = Cs.charat (i);
if (! Character.isletter (c) &&! Character.isdigit (c)) {
return false;
}
}
}
return true;
}
Java determines whether a mailbox is legitimate