From: "Wolfgang Nádasi-donner" Date: 2007-05-17T06:34:33+09:00 Subject: Re: Can't get subgroup of regex to repeat with +... what the Jon Fi wrote: > Ah ok. So how can I get it to repeat without overwriting the existing > values for the group? Or is there a better way to do this? I would do it somehow like: ========== code ========== texts = [ "", "", ""] texts.each do |txt| if (md=txt.match(/<(\w+?)((?:\s\w+=\w+)+)>/)) puts "\nkey '#{md[1]}' found" md[2].scan(/\s(\w+)=(\w+)/) do |k, v| puts " parameter '#{k}' has value '#{v}'" end else puts "+++ no match for '#{txt}'" end end ========= result ========= key 'orderMsg' found parameter 'biz' has value '0' key 'orderMsg' found parameter 'type' has value '7' parameter 'size' has value '0' key 'orderMsg' found parameter 'type' has value '7' parameter 'size' has value '0' parameter 'biz' has value '1' ========== end =========== Wolfgang Nádasi-Donner -- Posted via http://www.ruby-forum.com/.