开发者

C# & PLSQL - Finding Comments and Strings by RegExp

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开发者_如何学Go character sequence. Is there a solution, or are regular expressions simply the wrong way to handle this?

Best regards, Philipp


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜