From: William James Date: 2005-07-29T05:11:01+09:00 Subject: Re: Sed -> Ruby : .. and ... Keith Fahlgren wrote: > Here's the one I have problems with (we had a working Perl equivalent > but are trying to abandon Perl). > > sed: > /BEGIN RANGE/,/END RANGE/{ > s/MATCH/REPLACEMENT/g > } > > ruby: > [same beginning] > if working_file =~ /BEGIN RANGE/ .. working_file =~ /END RANGE/ > # INCLUSIVE use ... if you want non inclusive > working_file.sub!(/MATCH/,'REPLACEMENT') > end > [same ending] ruby -pe 'gsub(/e/, "-") if $_ =~ /START/ .. $_ =~ /END/' infile >outfile