I’m trying to match C style comments form a file, but only if the comment don’t start with a certain labels introduced by @
For example from
/* some comment to match */ /* another comment. this should match also */ /*@special shouldn't match*/
Is this possible using regular expressions only?
I’m trying this using JavaScript implementation of regular expressions.
Breaks down as:
Use in ‘global’ and ‘dotall’ mode (e.g. the dot should match new lines as well)
The usual word of warning: As with all parsing jobs that are executed with regular expressions, this will fail on nested patterns and broken input.
emk points out a nice example of (otherwise valid) input that will cause this expression to break. This can’t be helped, regex is not for parsing. If you are positive that things like this can never occur in your input, a regex might still work for you.