From: Inaba Hiroto Date: 1998-11-01T03:04:18+09:00 Subject: [ruby-dev:3565] string[/regexp/] 稲葉です。 1.1c6のstring.cを見ていたら、str_arefにcase T_REGEXP:という行があるの で、「えっ、そんな機能あるの?」と思って以下を実行してみたら、 % ruby -e 'str = "foo"; p str[/o*$/]' /tmp/rba00669:1: [BUG] Segmentation fault となりました。case T_STRING:もあって、こちらの方は % ruby -e 'str = "foo"; p str["oo"]' "oo" となって一応動作しているようなんですが。 まあマニュアルのどこにも書いてない機能なんですが、一応使えてもいいと思っ て、適当に修正してみました。 --- string.c.org Mon Sep 14 15:48:01 1998 +++ string.c Sat Oct 31 04:16:14 1998 @@ -802,8 +802,8 @@ return INT2FIX(RSTRING(str)->ptr[idx] & 0xff); case T_REGEXP: - if (str_match(str, indx)) - return reg_last_match(0); + if (reg_match(indx, str)) + return reg_last_match(backref_get()); return Qnil; case T_STRING: -- 稲葉 浩人 (inaba@st.rim.or.jp)