>>>>> "W" == Wyss Clemens <WYS / helbling.ch> writes:

W> A  bug, or are making wrong use of regexps (maybe the \1)?

 No, no. You have a regexp which is really complex.

W> str =~
W> /^function\s*(.*?)\s*[(](.*?)[)]\s*return\s*(.*?)\s*is\s*(.*?)begin\s*(.*?)end\s*\1\s*[;]/m  

 Imagine that your regexp fail (like in your example), ruby must try all
 possibilities for each (.*?). This is why it take so many times.

 If you really want to do it with a regexp (you're in a case where it's
 best handled by a parser) you must write a really simple regexp then
 retrieve the different components from the match.

 Something like this :

   r = /^function\s*(\w+)\s*\(([^)]*)\)(.*?)\bend\s+\1\s*;/m
   str.scan(r) do |a, b, c|
      p a, b, c
   end


 then you can retrieve the different values from $3


Guy Decoux