package cn.itcast_02;
import java.util.Scanner;
/*
*
* 判断功能
* String类的punlic static matches (String regex);
*/
public class 正则表达式的判断功能{
public static void main(String[] args) {
Scanner sc =new Scanner(System.in);
System.out.println("请输入号码");
String email = sc.nextLine();
//定义邮箱规则
String regex = "[a-zA-Z_0-9]+@[a-z_0-9] {2,6}(\\.[a-zA-z_0-9] {2,3})+";
//String regex = "\\w+@\\w {2,6}(\\.\\w {2,3})+";
//调用功能,判断
boolean flag = email.matches(regex);
//输出结果
System.out.println(flag);
}
}
1.正则表达式概述和基本使用
2.正则表达式规则的简单介绍
3.正则表达式的判断功能之邮箱号的判定
4.正则表达式之分割功能和练习1
5.正则表达式之分割功能练习2
6.正则表达式的替换功能
7.正则表达式的获取
8.获取Pattern概述