Hi -- On Fri, 23 May 2003, Dave Oshel wrote: > [~/Desktop] dave$ cat foobar.rb ; foobar.rb > #!/usr/local/bin/ruby > > # get a Stanislaw Lem quote containing underscores and backspaces, then > # replace the word following the deleted underscores and backspaces > # with the same word surrounded by emphatic arrow glyphs > > `fortune -m Nillity`.each do |x| > x.sub!( /(_+\010+)([a-zA-Z]+)/, "-->#{$2}<--" ) > print x > end > The word "does" should appear between the --><-- glyphs: > > -->does<-- > > but it doesn't. What am I overlooking? I'll admit to being a Perl > convert, so maybe I'm trying to do something non-Ruby? You're just using an uninitialized variable -- you can do that in Ruby as well as other languages :-) But anyway... to do the backreferencing you want, you have to use a different notation: irb(main):001:0> "abcde".sub(/.(.)/,"\\1") => "bcde" or '\1' (depending which version of quote marks you need). David -- David Alan Black home: dblack / superlink.net work: blackdav / shu.edu Web: http://pirate.shu.edu/~blackdav