Interrupt a long-running "infinite" Java regular expression

From , 5 Years ago, written in Java, viewed 222 times.
URL https://pastebin.vip/view/021bbc7e
  1.     LongRunningRegexExample.java
  2.     public class LongRunningRegexExample
  3.     {
  4.      public static void main(String[] args) throws InterruptedException
  5.     {
  6.       final Pattern pattern = Pattern.compile("(0*)*A");
  7.       final String input = "00000000000000000000000000";
  8.       long startTime = System.currentTimeMillis();
  9.       Matcher matcher = pattern.matcher(input);
  10.       matcher.find(); // runs for a long time!
  11.       System.out.println("Regex took:" + (System.currentTimeMillis() - startTime) + "ms");
  12.     }
  13.   }
  14. //源代码片段来自云代码http://yuncode.net
  15.                        

Reply to "Interrupt a long-running "infinite" Java regular expression"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website