1.不能全是相同的数字或者字母(如:000000、111111、222222、333333等等)
2.不能是连续数字(如:123456、12345678、87654321等等)
java或者正则表达式如何判断字符串不是相同数字或者字母?不能全是连续数字?(最好是java)
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
3条回答 默认 最新
alvin198761 2013-05-22 09:42关注[code="java"]
//顺序表
static String orderStr = "";
static {
for (int i = 33; i < 127; i++) {
orderStr += Character.toChars(i)[0];
}
}
//判断是否有顺序
public static boolean isOrder(String str) {
if (!str.matches("((\d)|([a-z])|([A-Z]))+")) {
return false;
}
return orderStr.contains(str);
}
//判断是否相同
public static boolean isSame(String str) {
String regex = str.substring(0, 1) + "{" + str.length() + "}";
return str.matches(regex);
}
[/code]本回答被题主选为最佳回答 , 对您是否有帮助呢?评论 打赏 举报解决 1无用