title: Parsing Java syntax with regex
body: <p>I am currently developing a corrector for java in my text editor. To do so I think the best way is to use Pattern to look for element of java syntax (import or package declaration, class or method declaration...). I have already written some of these pattern:</p>
  
  <pre><code>private String regimport = "^import(\\s+)(static |)(\\w+\\.)*(\\w+)(\\s*);(\\s*)$",
                  regpackage="^package(\\s+)[\\w+\\.]*[\\w+](\\s*);(\\s*)$",
                  regclass="^((public(\\s+)abstract)|(abstract)|(public)|(final)|(public(\\s+)final)|)(\\s+)class(\\s+)(\\w+)(((\\s+)(extends|implements)(\\s+)(\\w+))|)(\\s*)(\\{)?(\\s*)$";
  </code></pre>
  
  <p>It's not very difficult for now but I am afraid it will take a long time to achieve it. Does someone know if something similar already exists?</p>