Path: utzoo!attcan!uunet!mcvax!hp4nl!philmds!leo From: leo@philmds.UUCP (Leo de Wit) Newsgroups: comp.lang.c Subject: Re: not the way ... (was Re: Want a way to strip comments from a) Message-ID: <982@philmds.UUCP> Date: 17 Mar 89 19:38:47 GMT References: <7150@siemens.UUCP> <9900010@bradley> <4221@omepd.UUCP> <981@philmds.UUCP> Reply-To: leo@philmds.UUCP (Leo de Wit) Organization: Philips I&E DTS Eindhoven Lines: 16 In article <981@philmds.UUCP> leo@philmds.UUCP (Leo de Wit) writes: |Sed is often underestimated; it IS powerful enough: | |s/\/\*\([^*/]*\*\)\1*\///g | |will eat the comments away just nicely (I'll leave the HOW as an |exercise for the reader). Shame on me. That it works is merely a coincidence (put a * in a comment and see it fail). \1 matches the previous string matching a \( \) expression, not the expression itself. And since sed doesn't like \( \)* type expressions, this would be hard to do in one regexpr. Can it be proven to be impossible (that is, deleting the comments with one sed command - multi-line comments not considered) ? Leo.