On Sep 27, 2004, at 4:39 PM, Matthew Margolis wrote: > The code below is supposed to scan through a string and put a ',' > before all zip codes. The code properly detects the zip codes and > makes the change in x but the change is never reflected in thestring. > How can I get these changes to exist outside of x's scope? > > thestring.each do |x| > if x =~ /\d{5}/ > puts "match" > x[-6] = "," > puts x > end > end What about: thestring.gsub!(/(\d{5})/, '\1') That help? James Edward Gray II