这个while循环在哪里结束?

时间:2017-11-27 06:33:28

标签: loops while-loop

我在网上看到了关于正则表达式的代码。我无法理解外部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.");    
            }    
        }    

请解释一下!

0 个答案:

没有答案