Alex Young
4/17/2007 4:39:00 PM
Guest wrote:
> Okay had such a great response before and learned lots but how about
> another question?
>
> have some strings such as:
>
> blahblah /* comment */
> blahblah
> blah blah
> blah blah blah /* comment etc */
>
> And i want just the blahblah bit, not any comments if there are any.
> Any ideas on how to do this using a single regex would be most welcome,
> I know I'm pushing my luck :)
>
You're best off doing this the other way around (untested):
str.gsub(/\/\*.*?\*\//m, '')
That way you're stripping the comments out of the string, rather than
trying to find bits of the string that happen not to be in comments.
I'm not sure it's possible to simply do the latter, but I'm sure someone
will be along in a few moments to prove me wrong :-)
--
Alex