【发布时间】:2013-04-04 10:06:48
【问题描述】:
如何打印正则表达式模式不匹配的列号和行号。
我当前的代码:
reader = new BufferedReader(new FileReader(credentialPath));
Pattern pattern = Pattern
.compile(ApplicationLiterals.CREDENTIALS_URL_REG_EX);
String line;
while ((line = reader.readLine()) != null) {
Matcher matcher = pattern.matcher(line.trim());
if (matcher.find()) {
// System.out.println(matcher.group());
// System.out.println("**" + matcher.start());
// System.out.println("***" + matcher.end());
result = true;
count1++;
} else {
// count1++;
result = false;
// System.out.println(matcher.group());
// System.out.println(matcher.start());
System.out.println("****problem at line number" + count1);
break;
}
}
【问题讨论】:
-
那么您在执行此操作时遇到了什么问题?
-
我无法打印内容不匹配的确切位置。
-
它抛出了什么错误?如果没有任何错误,那么错误的输出是什么?
-
当我尝试打印 start end 或 group 方法时抛出非法状态异常
标签: java regex expression