From: dblack@... Date: 2003-05-23T09:22:51+09:00 Subject: Re: why is "does" missing from this sub!-stitution? Hi -- On Fri, 23 May 2003, Dave Oshel wrote: > In article <20030522202818.GA24497@student.ei.uni-stuttgart.de>, > Mauricio Fern�ndez wrote: > > > use > > x.sub!( /(_+\010+)([a-zA-Z]+)/ ) { "-->#{$2}<--" } > > Maybe so, but this works as expected: > > `/sw/bin/fortune -m Nillity`.each { |x| > x.sub!( /(_+\010+)([a-zA-Z]+\b)/, "" + '\2' + "" ) > print x > } > > Maybe it's a bug ... or a feature ... or a bug ... or a bug AND a > feature ... ;-) Here's an interesting illustration of the persistence of $1: >> str = "Hello there." => "Hello there." >> str2 = "A bunch of words." => "A bunch of words." >> if /(Hello) (there)/.match(str); str2.sub!(/(A)/, $1); end => "Hello bunch of words." >> str2 => "Hello bunch of words." >> $1 => "A" So... it all depends what you want to do. (I haven't actually thought of a case where I'd want to do the above, but still :-) David -- David Alan Black home: dblack@superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav