Reputation: 11
Is it possible to distinguish between code, strings and comments by using regular expressions? I'm trying to build a formatter for PLSQL-Code in C# and I can't manage to solve the problem, that strings, respectively quotes ( " or ' ) can also appear in comments, negating their special character and vice versa, comment indicators ( -- or /* ) appearing in strings, being nullified as a special character sequence. Is there a solution, or are regular expressions simply the wrong way to handle this?
Best regards, Philipp
Upvotes: 1
Views: 204
Reputation: 10648
You might find an idea how to reliably identify comments by studying a source code of Perl module Regexp::Common::comment. The module supports matching also PL/SQL comments.
Upvotes: 1