Remove multiline C style / * comments * / with Perl regex
How to remove multi-line C style comments like:
/* comments
comments
comments
comments */
I can remove comments on the same line, for example /* comments */
using multiple codes provided in other questions.
s#/\*[\s\S]*?\*/##sg;
s#/\*(.*?)\*/##sg;
s#/\*[^*]*\*+([^/*][^*]*\*+)*/|("(\\.|[^"\\])*"|'(\\.|[^'\\])*'|.[^/"'\\]*)#defined $2 ? $2 : ""#gse
All three regular expressions above do not work with multiline comments. How can they be handled?
+3
source to share