博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
判断email格式的正则表达式
阅读量:6977 次
发布时间:2019-06-27

本文共 1166 字,大约阅读时间需要 3 分钟。

常用的几个:

^[_/.0-9a-z-]+@([0-9a-z][0-9a-z-]+/.)+[a-z]{2,3}$

^[_a-z0-9-]+(/.[_a-z0-9-]+)*@[a-z0-9-]+(/.[a-z0-9-]+)*$
^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2}|net|com|gov|mil|org|edu|int)$
^([a-z0-9A-Z]+[-|//.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?//.)+[a-zA-Z]{2,}$
/w+([-+.]/w+)*@/w+([-.]/w+)*/./w+([-.]/w+)*

在JAVA中使用:

 

import java.sql.*;

import java.io.*;
import java.util.regex.*;

public class test{

 public static void main(String[] args){
  try{
   String s = "";
   while(!s.equals("q")){
    System.out.print("input:");
    DataInputStream in = new DataInputStream(new BufferedInputStream(System.in));
    s = in.readLine();
    System.out.println("your input is :"+s);
    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(s);
                boolean isMatched = matcher.matches();
                if(isMatched){
                 System.out.println("it's a email");
             }else{
              System.out.println("it's not a email");
             } 
    
   }
        }catch(Exception e){
         System.out.println("error"+e.getMessage());
     }
 }         

文章转自庄周梦蝶  ,原文发布5.16

评论

 re: 判断email格式的正则表达式[未登录]       

2008-04-18 11:27 by 
挺好的 谢谢!

转载地址:http://drypl.baihongyu.com/

你可能感兴趣的文章
企业网络翻译官——DNS
查看>>
RocketMQ3.2.2生产者发送消息自动创建Topic队列数无法超过4个
查看>>
USG防火墙telnet实验
查看>>
[给12306支招]取消车票预订-采用全额预售(充值)
查看>>
linux下使profile和.bash_profile立即生效的方法
查看>>
Operations Manager 2012 SP1配置部署系列之(二) SCOM监控SCVMM
查看>>
父域与子域之的信任关系
查看>>
Android中后台定时任务实现,即时数据同步问题思考!
查看>>
开启笔记本win7的虚拟热点,让你的本本变成wifi
查看>>
ETL数据抽取策略
查看>>
Python学习day5作业-ATM和购物商城
查看>>
Kubernetes基于Metrics Server的HPA
查看>>
比尔盖茨护犊子 称iPad让大批用户沮丧
查看>>
js 中文匹配正则
查看>>
pkg mysql 在macOS 上的管理
查看>>
将数组A中的内容和数组B中的内容进行交换(数组一样大)
查看>>
Nginx 负载均衡
查看>>
聊聊jesque的几个dao
查看>>
数据结构:二分查找 java
查看>>
docker-dockerfile
查看>>