From: Shin'ya Adzumi Date: 2001-09-06T13:56:00+09:00 Subject: [ruby-list:31279] Re: p "123".tr('=-;', ' =−; ') あづみです。 WATANABE Hirofumi wrote: > @@ -99,11 +99,11 @@ > a = [] > - str.scan(/(.)-(.)|(.)/m) do |r| > - if $3 > - a.push $3 > - elsif $1.length != $2.length > - next > - elsif $1.length == 1 > - $1[0].upto($2[0]) { |c| a.push c.chr } > + str.scan(/(?:\\([-\\]))|(.)-(.)|(.)/m) do > + if s = $1 || $4 > + a.push s > + elsif $2.length != $3.length > + next > + elsif $2.length == 1 > + $2[0].upto($3[0]) { |c| a.push c.chr } > else > - $1.upto($2) { |c| a.push c } > + $2.upto($3) { |c| a.push c } > end 私も真っ先にこれが思いついたんですが、これだと '\--/' が判別できないの でちょっとまずいかなと。 安積伸弥 adzumi@denpa.org