samedi 18 avril 2015

Java regex can't work,but javascript can work

My java regex is



Pattern compile = Pattern.compile("^((?:[^\\n]+\\n?)+)\\n*");
String a = "# clj-markdown\n\nA Clojure library designed to ... well, that part is up to you.\n\n## Usage\nFIX==ME==\n\n## License\n\nCopyright © 2015 FIXME\n\nDistributed under the Eclipse Public License either version 1.0 or (at\nyour option) any later version.\n";
System.out.print(compile.matcher(a));
System.out.print(compile.matcher(a).matches());


this output false,but I test in javascript can pass.



/^((?:[^\n]+\n?)+)\n*/.text(b)


how to resolve this problem?


may be this is java regex difference of javascript regex.


Aucun commentaire:

Enregistrer un commentaire