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.
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?