java邮箱正确性验证
程序员文章站
2024-03-19 14:06:22
...
判断邮箱输入是否正确:
import java.util.Arrays;
import java.util.Scanner;
public class Main
{
public static void main(String args[]){
Scanner scan = new Scanner(System.in);
String str1 = scan.nextLine();
char[] c1 = str1.toCharArray();
int a = 0,b=0,c=0;
for(int i=0;i<str1.length();i++){
int num = (int)c1[i];
if(num==64){
int numl = (int)c1[i-1];
int numn = (int)c1[i+1];
int numn1 = (int)c1[i+2];
int numn2 = (int)c1[i+3];
if(((numl>=97&&numl<=122)||(numl>=65&&numl<=90)||(numl>=48&&numl<=57)) && ((numn>=97&&numn<=122)||(numn>=65&&numn<=90)||(numn>=48&&numn<=57))){
a=0;
}else{
a=1;
}
}
if(num == 46){
int numl = (int)c1[i-1];
int numn = (int)c1[i+1];
int numn1 = (int)c1[i+2];
int numn2 = (int)c1[i+3];
if(numn == 90&&numn1 == 111&&numn2 == 109 ){
b=0;
}else{
b=1;
}
}
if(num ==95&&((num>=97&&num<=122)||(num>=65&&num<=90)||(num>=48&&num<=57))){
c=0;
}else{
c=1;
}
}
if(a==1&&b==1&&c==1){
System.out.print("NO");
}else{
System.out.print("YES");
}
}
}
上一篇: Rsync未授权访问漏洞的修复
下一篇: md5加密工具类
推荐阅读
-
java邮箱正确性验证
-
Java多线程测试springboot的并发响应返回正确性
-
Java 添加、验证PDF 数字签名
-
Java代码实现数字签名验证
-
随机生成验证码 博客分类: java JSPJavaScriptCacheHTML
-
验证码机制实现 博客分类: java ServletSwingJavaScriptSUN工作
-
java获取ip地址和验证ip是否合法。 javaHttpServletRequestipX-Forwarded-For
-
Java后台邮箱格式验证 博客分类: 随笔java Java格式验证
-
使用java.util.regex.*包验证email 博客分类: java JavaBlog
-
使用java.util.regex.*包验证email 博客分类: java JavaBlog