From: Michael Hollins Date: 2007-07-20T11:19:59+09:00 Subject: Re: simple question anitawa wrote: > hello > > I have a string like this > > string = "hello -a apple -b butterfly -c cat -d dophin" > > i would like to parse the string based on some reg exp so that i can > store it in a variable like so. > > valuea = "apple" > valueb = "butterfly" > valuec = "cat" > valued = "dophin" > > Could someone help me out. > Are you parsing a command line? If so, you might want to consider http://www.ruby-doc.org/stdlib/libdoc/optparse/rdoc/index.html cheers, mick