I'm parsing multiple double quoted literal text from a Visual Basic 6 Source file. Some lines may have comments at the end of each statement. Each comment is preceded by a single quote. In addition, the literal text may have single quotes which I need to retain. The line below is an example of a statement with a comment at the end.
Example Line: MsgBox "Must enter at least 2 'characters' before doing a Healthcare Data Dictionary Search.", vbInformation, "Search HDD" 'This is a "comment".
The following Regular Expression will return:
Must enter at least 2 'characters' before doing a Healthcare Data Dictionary Search.
Search HDD
comment
The following Regular Expression will capture/parse multiple double quoted string literals, however it does not ignore double quoted strings that come after a single quote (within a comment).
Regular Expression: "([^""]*)(?:\.[^""\\])*"
C#-Style: @"""([^""""]*)(?:\.[^""""\\])*"""
I would like to be able to strip off the comment however if I look for a single quote, that single quote could potentially be in the double quoted string I want to keep, thus stripping off half the double quoted string.
Please let me know if this is not clear and I'll try to clarify.
Any suggestions?