r=[] while s=~/([-+*\/]|\d+)(.*)/ do r<<$1 ; s=$2 end r # に、トークンの配列が作られている