szabivan

pairseq

Feb 18th, 2015
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.42 KB | None | 0 0
  1. Pattern pattern1 = Pattern.compile( "(?:(.)\\1|.0|0.)*" ); // BAD, 00 matches at least two options within iteration
  2. Pattern pattern2 = Pattern.compile( "(?:(.)\\1|[^0]0|0[^0])*" ); // GOOD, options are made disjoint
  3. Pattern pattern3 = Pattern.compile( "(?>(.)\\1|.0|0.)*" ); // GOOD, prefix-free sets can be made atomic safely
  4.  
  5. Matcher matcher = pattern1.matcher( "000000000000000000000000000000000" );
  6. matcher.matches();
Advertisement
Add Comment
Please, Sign In to add comment