如果我的清单是
[('IL', 36), ('NJ', 81), ('CA', 81), ('DC', 52), ('TX', 39)],
我该如何排序才能得到结果
[('CA', 81), ('NJ', 81), ('DC', 52), ('TX', 39), ('IL', 36)]?
我正在写一个由 4 个大写字母组成的Pattern匹配 a String。
例如:
...都是正确的匹配,而:
...不应该匹配。
在下面找到我的代码。
它不断返回false“AAAA”。
任何人都可以对此有所了解吗?
public static boolean checkSettings(String str) {
Pattern p = Pattern.compile("\\p{Upper}{4}");
Matcher m = p.matcher("%str".format(str));
if (m.matches()) {
return true;
} else {
// System.exit(1)
return false;
}
}
Run Code Online (Sandbox Code Playgroud) 为了".*?([a-m/]*).*"匹配字符串"fall/2005",我认为".*"将匹配任何字符0次或更多次.但是,由于存在?以下内容.*,因此仅匹配0或1次重复.所以我认为.*?会匹配,'f'但我错了.
我的逻辑有什么问题?