I am trying to find all VBA comments using regular expressions. I have something that mostly works, but there are a few exceptions that I cannot figure out.
Expression I
Maybe something like
^(?:[^"'\n]*("(?:[^"\n]|"")*"))*[^"]*'(.*)$
It handles multiple quoted strings, as well as strings having quoted (double) "'s (which I believe is VBA's way).
(I guarantee it will fail in some cases, but probably will work in most ;)
Check it out here at regex101.
Edit
Added some of Comintern's examples and adjusted the regex. It still can't handle the bracketed identifiers though (which I don't even know what it means :S See the last line). But it now handles his continued line comments.
^(?:[^"'\n]*(?:"(?:[^"\n]|"")*"))*[^']*('(?:_\n|.)*)
Check it out here at regex101.