On 5/17/07, Jon <exabrial / gmail.com> wrote: > > Example Strings: > ===== > A=" <orderMsg biz=0>" > B=" <orderMsg type=7 size=0>" > C=" <orderMsg type=7 size=0 biz=1>" > ===== > > I've come up with this regex: > ===== > /<(\w+?)(?:\s(\w+)=(\w+))+>/ > ===== > > > But when matching string B from above: > ===== > md=/<(\w+?)(?:\s(\w+)=(\w+))+>/.match(B) > ===== > > > Why isn't the final + sign making the pattern "(?:\s(\w+)=(\w+))" > repeat? > > As an exercise... /<(\w+?)(?:\s(\w+)=(\w+))(?:\s(\w+)=(\w+))>/ DOES > match String B from above. What the heck??? > > -- > Posted via http://www.ruby-forum.com/. > > Hi, Unless you really want to write one regular expression for it all, you could do something like this. Split on spaces, then on '=' . Then process however you want. r = B.strip.split(/\s/) p r r[1..-1].each {|f| p f.split("=")} Harry -- A Look into Japanese Ruby List in English http://www.kakueki.com/