From: Bob Gustafson Date: 2001-06-06T06:59:05+09:00 Subject: [ruby-talk:16251] Re: line numbers in multiline regular expressions. Jonas wrote earlier: >Hi, > >Here is my 5 minute attempt to create a program that extracts all >comments in a C source file containing the string "TODO": > >todo_comments = File. > open(ARGV[0], "r"). > read. > scan(/\/\*.*?\*\//m). > delete_if { |c| c !~ /TODO/ } > >It works fine, but I really would like to have access to the line number >where the scan matches. Is that easy to accomplish or do I have to >rethink the structure of the program from scratch? > >/j It looks like you are only looking at lines which have both /* and */. This may not be what you want. You could try: grep -n TODO filename :-) This would be a good benchmark for timing in any case. Regards BobG