第13次作业--邮箱的正则表达式

题目:定义判断电子邮箱的正则表达式,判断输入的字符串是否为电子邮箱地址。

代码:

import java.util.*;

public class email {

    public static void main(String[] args) {
        System.out.println("输入邮箱");
        Scanner a = new Scanner(System.in);
        String s = a.next();
        String regex = "[a-zA-Z]*+[0-9]{6,20}+@{1}+((163){1}|(qq){1}|(sina){1})+.{1}+com{1}";
        if (s.matches(regex))
            System.out.println("这个邮箱正确");
        else
            System.out.println("这个邮箱不正确");

    }
}

 运行结果:

posted @ 2019-11-24 12:50  jhyjhy  阅读(123)  评论(0编辑  收藏  举报