From: Brian Candler Date: 2008-09-18T21:54:55+09:00 Subject: Re: Suggestion for string parsing > is there a way to use the scanf to parse a string not knowing how many > chars? I'd still use Regexp. line="Client=MPEG-4,390000,700000,24000" val1,val2,val3,val4,val5 = /^(\w*)=([^,]*),(\d*),(\d*),(\d*)/.match(line).captures Another way: def handle_line(v1,v2,v3,v4,v5) puts "I got it! #{v1} etc" end ... if /^(\w*)=([^,]*),(\d*),(\d*),(\d*)/ =~ line handle_line(*$~.captures) end -- Posted via http://www.ruby-forum.com/.