Here you go, but I just had to make one change. Instead of having variables
valuea, valueb, valuec..., I put them in a hash called value. Is it absolutely
necessary to have them as you posted?
string.split(/\s-/).each do |v|
v = v.split(/\s/)
value[ v[0] ] = v[1] if v.size == 2
end
"Programming in Java is like dealing with your mom --
it's kind, forgiving, and gently chastising.
Programming in C++ is like dealing with a disgruntled
girlfriend -- it's cold, unforgiving, and doesn't tell
you what you've done wrong."
or a gem called 'OptionParser'. It's like optparse, only, I find, a lot simpler.
ยทยทยท
On Jul 19, 2007, at 10:19 PM, Michael Hollins wrote:
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.