I have to write simple BibTeX parser using Java regular expressions. Task is a bit simplified: every tag value is between quotation marks ""
, not brackets {}
. The thing is, {}
can be inside ""
.
I'm trying to cut single records from entire String file, e. g. I want to get @book{...}
as String. The problem is that there can be no comma after last tag, so it can end like: author = "john"}
.
I've tried @\w*\{[\s\S]*?\}
, but it stops if I have }
in any tag value between ""
. There is also no guarantee that }
will be in separate line, it can be directly after last tag value (which may not end with "
either, since it can be an integer).
Can you help me with this?