package cn.zmh.正则;
public class RegexDemo {
?? ?public static void main(String[] args) {
?? ??? ?checkMail();
?? ??? ?split_2();
?? ??? ?split_1();
?? ?}
?? ?//邮箱
?? ?public static void checkMail(){
?? ??? ?String email = "[email?protected]";
?? ??? ?boolean b = email.matches("[a-zA-Z0-9][email?protected][0-9a-z]+(.[a-z]+)+");?? ??? ?System.out.println(b);?? ?}??? //? 19???? 89??? 12?? ?public static void split_2(){?? ??? ?String st = "19? 89? 12";?? ??? ?String[] s = st.split(" ");?? ??? ?System.out.println("长度为"+s.length);?? ??? ?for(int i=0;i<s.length;i++){?? ??? ??? ?System.out.println(s[i]);?? ??? ?}?? ?}?? ?// String split()?? ?public static void split_1(){?? ??? ?String st = "2019-03-19-10-51";?? ??? ?//按照-对字符串进行切割?? ??? ?String[] stArr = st.split("-");?? ??? ?System.out.println("长度为:"+stArr.length);?? ??? ?for(int i=0;i<stArr.length;i++){?? ??? ??? ?System.out.println(stArr[i]);?? ??? ?}?? ?}}