zuma53 has asked for the wisdom of the Perl Monks concerning the following question:
Hi--
I am working on some SQL files where rest-of-line comments are denoted by '--'. Everything to the right of this tag is considered a comment. However, all this gets gummed up by the presence of single quotes. Embedded '--''s in strings are not comment anchors.
Example:
select 'text' from foo --This is a comment select '--Not a valid comment' from foo --But this is select '--This is not a valid comment' from foo select '--Not this' + '--either' from foo
What I'd like is to strip out the comments. I can do this programmatically, though tedious, by counting quotations, but is there a way to do this in a regex?
Thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex: Identifying comments
by choroba (Cardinal) on Aug 29, 2012 at 14:33 UTC | |
|
Re: Regex: Identifying comments
by Athanasius (Archbishop) on Aug 29, 2012 at 14:40 UTC | |
by RichardK (Parson) on Aug 29, 2012 at 15:03 UTC | |
by zuma53 (Beadle) on Aug 29, 2012 at 15:49 UTC | |
by choroba (Cardinal) on Aug 29, 2012 at 16:02 UTC | |
|
Re: Regex: Identifying comments
by pvaldes (Chaplain) on Aug 30, 2012 at 10:06 UTC | |
|
Re: Regex: Identifying comments
by remiah (Hermit) on Aug 30, 2012 at 13:53 UTC | |
by pvaldes (Chaplain) on Aug 30, 2012 at 18:29 UTC | |
by remiah (Hermit) on Aug 30, 2012 at 21:58 UTC | |
by pvaldes (Chaplain) on Aug 30, 2012 at 23:42 UTC | |
by remiah (Hermit) on Aug 31, 2012 at 05:37 UTC | |
|