Search code examples
regexbnf

What is the BNF for a regex (in order to write a full or partial parser)


I am interested in parsing regexes (not to be confused with using regexes for parsing). Is there a BNF for Java 1.6 regexes (or other languages?)

[NOTE: There is a similar older question which did not lead to an answer for Java.]

EDIT To explain why I need to do this. We are implementing a shallow parser for Natural language processing which first identifies and tags tokens. These are then further processed with a regex. I need to know what groups have been captured by the regex (the automaton only captures the last of each bracket) and I also want to annotate the regex with comments.


Solution

  • There does not seem to be an explicit regex according to SO replies.