public class ZhengZe {
public static void main(String[] args) {
// TODO Auto-generated method stub
//使用正则进行匹配
String mail="lishuai_zhangsan@qq.com.com.cbn";
String regex="\\w+@\\w+(\\.+\\w+){1,3}";
boolean boo=mail.matches(regex);
System.out.println(boo);
//切割字符串
String str="aaa?dad??????frad????????????;afaaf、?ADafa";
//使用叠词来切割时需要使用正则
String[] s=str.split("(.)\\1+");
for (String string : s) {
System.out.println(string);
}
}
}
网友评论