I'm trying to determine how many classes are declared in a .java file, using only that file type (can't compile and just count .class files).
I found some acceptable ways to do this, however I don't like being sloppy with anything I do. I'd like to learn how to do it more robustly, i.e. take into account fringe possibilities like this:
this is actually a block comment with class in it*/
//in line comment that contains class keyword
"string with class in it"
Regex is something very new to me, I just went through some tutorials but can't seem to find or properly articulate an expression that will match cases like these.
Would greatly appreciate any kind insight and help.
Thank you!