MySQL has a very nasty comment syntax, it can either be
a
# all the way up to the end of the line,
a double hyphen followed by a space all the way up to the
end of the line, or a
/* up to either a semicolon
or a
*/, except when either of them is inside
a single or double quoted string.
Here's a regex to actually match such a comment (will be in
Regexp::Common version 0.03).
(?:#|-- )[^\n]*\n|/\*(?:(?>[^*;"']+)|"[^"]*"|'[^']*'|\*(?!/))*(?:;|\*/
+)