From: Jeff Cohen Date: 2006-09-14T01:17:31+09:00 Subject: Re: Regular expression question. L7 wrote: > In trying to parse a C source file I have the following section of > code: > > ... > ... > case line > when /^.*\/\*.*?\*\/.*$/ # single line comment(s) > non_comments = line.split(/\/\*.*?\*\//).to_s > process_code(non_comments) > when /^.*\/\*\*?[^(\*\/)]*$/ # multi-line start > comment = true > next > when /^[^(\/\*)]*\*\/.*$/ # multi-line end > comment = false > ... > ... > > I am running into a problem with the multi-line comment sections. > My eyes glaze over with these kinds of expressions, but this might help: http://www.regularexpressions.info/examplesprogrammer.html Scroll down the section on "Comments". They seem to have a simpler solution, I think the trick is to be able to use . as matching newlines. And you can turn on newline matching in Ruby by putting an "m" after the expression: /my_pattern_here/m Hope this helps...? Jeff softiesonrails.com -- Posted via http://www.ruby-forum.com/.