Article 9436 of comp.lang.perl:
Xref: feenix.metronet.com comp.lang.perl:9436
Newsgroups: comp.lang.perl
Path: feenix.metronet.com!news.utdallas.edu!corpgate!bnrgate!bnr.co.uk!uknet!pipex!uunet!psinntp!shellgate!shell!rjohnson
From: [email protected] (Roy Johnson)
Subject: Re: Finding C comments
In-Reply-To: [email protected]'s message of 04 Jan 1994 17:24:58 GMT
Message-ID: <[email protected]>
Sender: [email protected] (USENET News System)
Organization: Houston, TX
References: <[email protected]> <[email protected]>
       <[email protected]>
Date: Tue, 4 Jan 1994 21:50:05 GMT
Lines: 26

[email protected] (Randal L. Schwartz) writes:

> The right way to toss comments is to pull the string apart a little
> a time.  In Perl, it'd be something like this:

> $_ = "your string here";
> $left = ""; # temp
> while (//\*/) { # open comment?
>        $left .= $`;
>        $_ = $';
>        die "Unterminated comment" unless /\*\//;
>        $_ = $';
> }
> $_ = "$left$_"; # put parsed back into $_

And the wrong way, but one that works (credit Mark Biggar):

s#/\*/*([^*/]*\*)+/##g;

I thought this was in the FAQ, but I don't see it.  I hope it will be
in the next.
--
-------- Roy Johnson ---- [email protected] ---- Speaking for myself --------
"When the only tool you have is Perl, the whole | "Hooray for snakes!"
world begins to look like your oyster." -- Me  |  -- The Simpsons (29 Apr 93)
------- "We _love_ being politically Koreshed" -- Steve Taylor, "Smug" -------