我需要在一个看起来像这样的文件中匹配和解析数据:
4801-1-21-652-1-282098
4801-1-21-652-2-282098
4801-1-21-652-3-282098
4801-1-21-652-4-282098
4801-1-21-652-5-282098
但我下面写的模式似乎不起作用.有人可以帮我理解为什么吗?
final String patternStr = "(\\d+)-(\\d+)-(\\d+)-(\\d+)-(\\d+)-(\\d+)";
final Pattern p = Pattern.compile(patternStr);
while ((this.currentLine = this.reader.readLine()) != null) {
    final Matcher m = p.matcher(this.currentLine);
    if (m.matches()) {
        System.out.println("SUCCESS");
    }
}
看起来很正确.可能是你的行中有些奇怪的东西.寻找一些额外的空间和换行符.
试试这个:
final Matcher m = p.matcher(this.currentLine.trim());