From: Sebastian Hungerecker Date: 2007-09-19T19:41:05+09:00 Subject: Re: how can I remove all the comments in my c program. Vellingiri Arul wrote: > Dear Friends, > using The Ruby how can I remove all the comments in my c program. > For example I have mentioned c program ,that may be ruby program > for your purpose you assume. > I have tried to do using the regular expression. > But I was unable to find the anser for this. The most simple regexen would be %r(//.*$) to match single line comments and %r(/\*.*?\*/)m to match multiline comments, but these will give you some false positives - for example, when you use // or /* inside a string. If you want something that works reliably, you would need to use a C-parser rather than regular expressions. HTH, Sebastian -- NP: Porcupine Tree - Open Car Jabber: sepp2k@jabber.org ICQ: 205544826