Weeding out comments is not as easy as you might think:
println( "This starts a comment? // Or does it\n" ); <== match ? // /* print( "*/ What happens now ?\n" ); <== match ??
You will need a parser for your language that understands the basics of that language at least well enough to know when the "comment starter markers" are within a string and when they actually apply. There is Text::Balanced and Regexp::Common, which have prefabricated regexes that attempt this task, and if they are not suitable for the language you are trying to parse, Parse::RecDescent or Parse::YAPP can be used to write your own parser.
In reply to Re: RegEx - comments should not matches
by Corion
in thread RegEx - comments should not matches
by Chief of Chaos
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |