The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Scripting comments gliesian Shell Programming and Scripting 4 03-28-2008 05:32 AM
OMG BPMN 2: comments for CEP iBot Complex Event Processing RSS News 0 03-11-2008 09:20 AM
lint comments axes High Level Programming 5 01-05-2008 07:14 AM
Print comments in FTP lweegp UNIX for Dummies Questions & Answers 7 10-12-2005 05:55 PM

Closed Thread
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-11-2001
LivinFree's Avatar
Goober Extraordinaire
 

Join Date: Jul 2001
Location: Portland, OR, USA
Posts: 1,584
Remove comments...

It may be a no-brainer, but the answer is escaping me right now:

I'm trying to write a little script to remove all comments from .c source... I was thinking sed, but I'm not a very strong regexp user (e.g. I suck with sed).
I tried dumping the file into:
sed -e 's/\/\* * \*\///g'
and several variants of it, but I can't seem to get all of the comments out. The main issue is to remove multiline comments from programmers that think they should document ALL technical details in the beginning of the source, as opposed to putting it in a seperate file. The sources that I'm trying to make smaller (they're just slightly too big for a floppy) contain dozens of pages of comments for a relatively small .c file...
Forum Sponsor
  #2 (permalink)  
Old 10-11-2001
flim flam flamma jamma
 

Join Date: May 2001
Location: Chicago IL, USA
Posts: 1,006
if you happen to be able to view the book "Mastering Regualr Expresstions" by Oreilly page 171-174 are pretty much dedicated to writeing a regx for this very purpose.

taken from the book:

Code:
/\*[^*]*\*+([^/*][^*]*\*+)*/
but still needing some refined work due to comments offten span multi lines.
Google UNIX.COM
Closed Thread

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:36 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0