50,530
社区成员
发帖
与我相关
我的任务
分享
String str = "abc1ea";
Pattern p = Pattern.compile("([0-9a-df-np-zA-Z])\\1{1}");
Matcher m = p.matcher(str);
if(m.find()){
System.out.println(str);
}
else{
System.out.println("要打印包含连续重复字符,且不包含ee或oo的字符串");
}
参考博文:http://blog.csdn.net/atomcrazy/article/details/9087187
String str = "aeoeo";
Pattern p = Pattern.compile("(ee|oo)");
Matcher m = p.matcher(str);
if(!m.find()){
System.out.println(str);
}
else{
System.out.println("不打印包含ee或oo的字符串");
}