From: "中川 誠" Date: 1999-04-05T18:12:05+09:00 Subject: [ruby-list:13302] if 条件での範囲指定 中川と申します。 ruby 1.2.3(99/02/16) [i486-linux] を利用していて理解できない現象がありま すので、お聞きいたします。 次のようなデータに対して、 --- data from here --- ---------------+-------------------------------------- aaaa: test1 test2 test3 ---------------+-------------------------------------- --- data upto here --- このようなスクリプトを実行すると、 --- script from here --- while STDIN.gets if /^ +aaaa:/ ... /^ +-+/ print $_ end end --- script upto here --- このような結果になります。 --- result from here --- macon@nakagawa$ ruby test.rb < data.txt test2 test3 ---------------+-------------------------------------- --- result upto here --- sed では以下のようになりますが、これは意図された仕様なのでしょうか。sed の動作の方が納得がいくのですが。 macon@nakagawa$ sed -n '/^ *aaaa:/,/^ *--*/p' < data.txt aaaa: test1 test2 test3 ---------------+--------------------------------------