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

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



On Sun, Jan 19, 2003 at 02:39:59AM +0200, Lars Wirzenius wrote:
[snip]
> > 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.
[snip]

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:

	\/\*([^*]|\*[^/])*\*\/

However, if you it with grep it won't work, because grep is line-based,
and this will fail to catch multi-line comments. It is probably possible
to write a sed script that does this---sed is also line-based but it can
keep state, so you can work around the limitation.


T

-- 
Sometimes the best solution to morale problems is just to fire all of the
unhappy people. -- despair.com



Reply to: