in reply to RegEx - comments should not matches
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: RegEx - comments should not matches
by Chief of Chaos (Friar) on Jul 13, 2004 at 11:55 UTC | |
|
Re^2: RegEx - comments should not matches
by hardburn (Abbot) on Jul 13, 2004 at 16:13 UTC |