- package day25;
- /**
- *
- *
- */
- public class MatchDemo {
- public static void main(String[] args) {
- String str="9109499";
- matches_1(str);
- String mail="safhsiofh@fas3.con.cn";
- matches_2(mail);
- }
- public static void matches_1(String str){ //判断QQ号
-
- String reg="[1-9]\\d{5,13}";
- boolean flag=str.matches(reg);
- System.out.println("QQ="+flag);
-
- }
- public static void matches_2(String mail){ //判断邮箱
-
- String reg="[a-zA-Z0-9]+@[a-zA-Z0-9]+(\\.[a-zA-Z]+)+";
- boolean flag=mail.matches(reg);
- System.out.println("mail="+flag);
- }
- }
-
复制代码
|
|