public void test54() throws PatternCompiler_E, IOException { String reg = "^\\w+\n(\\s+.*\n)*\\s+student\n(\\s+(\\d+)\n){3}"; init( "\nPoint\n 66\n 32\nAlbert\n ...\n ¶àÐеļò½é,±ÈÈçÌس¤¡¢Ï²ºÃµÈ\n ...\n student\n 173\n 16\n 62\n", reg); matcher.clear(); matcher.add(reg, false); assertEquals(0, find()); }
private void init(String str, String regex) { System.out.println( "\n[TEST" + testIndex + "]#################################################\n"); ++testIndex; System.out.println(str); InputStream in = new BufferedInputStream(new ByteArrayInputStream(str.getBytes())); OutputStream out = new ByteArrayOutputStream(); matcher = new Matcher(in, out); try { matcher.add(regex); } catch (PatternCompiler_E ex) { ex.printStackTrace(); assertTrue("ÕýÔò±í´ïʽ´íÎó", false); } }