10,607
社区成员
发帖
与我相关
我的任务
分享
public static void main(String[] args) {
String str = "5201122";
Pattern p = Pattern.compile("\\d*(\\d)\\1(\\d)\\2\\d*");
Matcher m = p.matcher(str);
if(m.find()){
String s1 = m.group(1);
String s2 = m.group(2);
if (Integer.parseInt(s1)+1==Integer.parseInt(s2)){
System.out.println(m.group());
}
}
}
s = '5201133';
if(s == s.replace(/(.)\1(.)\2/, function(m, a, b) { return parseInt(a)+1 == b ? m : ''; }))
document.write('yes');
else
document.write('no');
s = '5201122';
if(s == s.replace(/(.)\1(.)\2/, function(m, a, b) { return parseInt(a)+1 == b ? m : ''; }))
document.write('yes');
else
document.write('no');