我在网上看到了关于正则表达式的代码。我无法理解外部while循环何时结束/破坏?
while (true) {
System.out.println("Enter regex pattern:");
Pattern pattern = Pattern.compile(sc.nextLine());
System.out.println("Enter text:");
Matcher matcher = pattern.matcher(sc.nextLine());
boolean found = false;
while (matcher.find()) {
System.out.println("I found the text "+matcher.group()+" starting at index "+
matcher.start()+" and ending at index "+matcher.end());
found = true;
}
if(!found){
System.out.println("No match found.");
}
}
请解释一下!