[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: C comment extraction, or a bag .deb of small commands



On Sat, 18 Jan 2003, H. S. Teoh wrote:
> > > By the way, I'm still interested in a regex one-liner.
> > It's beyond my capabilities: you're going to be needing something
> > stronger than standared regular expressions, I think.
>
> No you don't. But you *do* need real regex matching (as in, not just a
> per-line matching), which is provided by flex. Probably why flex is a
> good choice for this. The following (extended) regex should work:
>
> 	\/\*([^*]|\*[^/])*\*\/

I don't exactly know what you mean be "real" or "extended" regex ;) I do
know what e.g. perl means by extended regular expression, i.e. as a more
powerful but non-regular extension to regex.

But consider this example which is not covered by the above:

const char *a = "/*", b = "*/";

I still don't know about a one-liner for this task that covers all cases.
But I would consider to take a look at Jeffrey Friedl's "Mastering Regular
Expressions". IIRC it discusses a regex that does just that.

Have a nice weekend,
Jens

--
ruehmkorf at informatik dot uni hyphen koeln dot de



Reply to: