h={'十',' 10+','百',' ?d+','千',' 1000+',"\n",'+0'} i=0;'一二三四五六七八九'.scan(/./u){h[$&]=i+=1} $<.map{|s|p eval s.gsub(/./mu){h[$&]}.gsub(/\d /,'\&*')}