I've been looking for a simple way to find quoted strings of text within a Java source code file. First, I looked to regular expressions. Then I realized I had two problems, because as this answer stated, there isn't going to be a totally correct regex for this, similar to the problems that arise with markup languages. The main issue comes from the fact that there may be escaped quotation marks within a string.
So, what options do I have for parsing a source code file to find strings (possibly with escaped quotations) within? Is there anything that already exists for doing this? Preferably, it would be in Python.
EDIT: Here's some oversimplified example code.
private static String[] b = {
foo("HG@\"rND"),
foo("K1\\"),
bar("ab\\\\\\\"")
}
Any combination of backslashes should be able to be handled. The desired output would be the strings themself.