I need to build the tree representing a Java regular expression. java.util.regex.Pattern do the job, but its root field and Node inner class (and its subclasses) are not visible, so I can’t access them. I have to write my own parser and reimplement all the parsing logic?
I need to build the tree representing a Java regular expression. java.util.regex.Pattern do the
Share
You could use reflection to get at those private fields, or use an existing regex/PCRE parser: http://bkiers.github.com/PCREParser. Note that the PCREParser lib (of which I am the author) is never put to a real (unit) test: so if you’re planning on using it in production code, throw some proper unit tests against it! 🙂