From: Jonas Bengtsson Date: 2002-07-04T02:25:01+09:00 Subject: Regular Expression problems Hello, I got a problem with regular expressions in Ruby. The closest I have come to a solution looks like this: _________________________________________________________________ re = /\n(.*)( a little content containing all sorts of characters, even < and > also containing all sorts of things i don't know in advance how many of these there are but i settle with three here HERE match = re.match unprocessed while match name = match[1] content = match[2] unprocessed = match[3] puts "MATCH", "name:#{name}", "content:#{content}", "unproc:#{unprocessed}" match = re.match unprocessed end _________________________________________________________________ Here is the output: _________________________________________________________________ MATCH name:a_name content:a little content containing all sorts of characters, even < and > also containing all sorts of things i don't know in advance how many of these there are but i settle with three here _________________________________________________________________ But I want the output to look like this: _________________________________________________________________ MATCH name:a_name content:a little content containing all sorts of characters, even < and > name:another_name content:also containing all sorts of things name:third_name content:i don't know in advance how many of these there are but i settle with three here _________________________________________________________________ So the problem is that the second group--(.*)--is too 'hungry' and doesn't stop on the first occurrence of the third group--(