? How do I use RB RegEx to strip C/C++ style comments from string ? 
Author Message
 ? How do I use RB RegEx to strip C/C++ style comments from string ?

Hi:

I am looking for a way to use RB's RegEx (which i know little about)
to strip C/C++ style comments from a string. For example

/* I am a
multi-line
C-style comment */

//I am a one line C++ style comment

Can anybody help me?
Thanks much,
+ German



Wed, 15 Sep 2004 04:54:30 GMT  
 ? How do I use RB RegEx to strip C/C++ style comments from string ?

Quote:
> I am looking for a way to use RB's RegEx (which i know little about)
> to strip C/C++ style comments from a string. For example

> /* I am a
> multi-line
> C-style comment */

> //I am a one line C++ style comment

type RegEx+RealBasic at www.google.com


Thu, 16 Sep 2004 02:48:40 GMT  
 ? How do I use RB RegEx to strip C/C++ style comments from string ?


Quote:
> I am looking for a way to use RB's RegEx (which i know little about)
> to strip C/C++ style comments from a string. For example

> /* I am a
> multi-line
> C-style comment */

> //I am a one line C++ style comment

Is the problem that you don't know regular expressions? Then read Jeffrey
Friedl's book. Or is the problem that you don't know about the regex
class? Then read the online help.

m.

--

      *** REALbasic: The Definitive Guide! 2nd edition! ***
http://www.amazon.com/exec/obidos/ASIN/0596001770/somethingsbymatt



Thu, 16 Sep 2004 03:49:49 GMT  
 ? How do I use RB RegEx to strip C/C++ style comments from string ?
The problem is I do not know the RegEx syntax well enough but I need a
quick solution to describe a non-trivial string pattern such as below,
for example,  if you consider that c/c++ comments can be inside quoted
strings.
+ German
Quote:


> > I am looking for a way to use RB's RegEx (which i know little about)
> > to strip C/C++ style comments from a string. For example

> > /* I am a
> > multi-line
> > C-style comment */

> > //I am a one line C++ style comment

> Is the problem that you don't know regular expressions? Then read Jeffrey
> Friedl's book.



Thu, 16 Sep 2004 14:01:47 GMT  
 ? How do I use RB RegEx to strip C/C++ style comments from string ?


Quote:
> The problem is I do not know the RegEx syntax well enough but I need a
> quick solution to describe a non-trivial string pattern such as below,
> for example,  if you consider that c/c++ comments can be inside quoted
> strings

That point is extremely profound. Again I recommend you read Friedl's
book. Not every situation can be described in a single regular expression;
the syntax just isn't that powerful (and it can probably be shown, using
Turing or Godel or something, that it can never be). m.

--

      *** REALbasic: The Definitive Guide! 2nd edition! ***
http://www.amazon.com/exec/obidos/ASIN/0596001770/somethingsbymatt



Thu, 16 Sep 2004 22:27:08 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. to CS: or not to CS: in F-PC assembler

2. RB uses CPU even when doing nothing

3. Using Smalltalk to teach intro cs courses

4. UPG using CS.exe

5. using GOFER/MIRANDA in a first-year CS course (2)

6. using GOFER/MIRANDA in a first-year CS course

7. Intro CS book using Dylan?

8. Wanted: references on using Scheme for Intro CS courses

9. Using CS override

10. Error using string.strip

11. using string. vs regex/regsub: an example

12. using string vs regex/regsub: an example

 

 
Powered by phpBB® Forum Software