Hi -- On Fri, 26 Jun 2009, Wes Gamble wrote: > I am using the form of gsub that takes a block to determine what to > substitute. > > My problem is that I can't quite get the regex working, but I will be > able to detect that it matched incorrectly, once I can inspect the > backreferences in the block. > > So: if I determine via code in the substitution block that I don't want > to do the substitution, is there a way to simply abandon the gsub call > on that particular iteration? Just return the original: >>"abcdef".gsub(/./) {|s| if s == 'e' then s else 'z' end } => "zzzzez" David -- David A. Black / Ruby Power and Light, LLC Ruby/Rails consulting & training: http://www.rubypal.com Now available: The Well-Grounded Rubyist (http://manning.com/black2) "Ruby 1.9: What You Need To Know" Envycasts with David A. Black http://www.envycasts.com