Brian Candler wrote:
>> 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

thanks,
but what I would like to avoid regexp, it seems strange to me that 
there's no way to parse a string providing the structure.
scanf would be great but if I put %s it doesn't get the string, unless I 
put the number of chars.
-- 
Posted via http://www.ruby-forum.com/.