以下内容不返回任何匹配项:
String patternStr = "((19\\d{2}|20\\d{2})-([0-2]\\d{2}|3[0-5]\\d)-(([0-1]\\d|2[0-3])[0-5]\\d[0-5]\\d))";
String fullPath = aFile.getAbsolutePath();
// fullPath should expand to this: "/home/user1/2013-023-135159_abcd_001/File.txt"
Pattern p = Pattern.compile(patternStr);
Matcher m = p.matcher(fullPath);
if (m.matches())
{
System.out.println("Matches found");
}
它应该与日期部分匹配,2013-023-135159。我在线测试了它,正则表达式看起来没问题。
最佳答案
关于Java 正则表达式不匹配,正则表达式看起来正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29091487/