Heesob Park wrote: > 2009/4/29 Craig Jolicoeur <cpjolicoeur / gmail.com>: >> ## to >> ## from (irb):84 >> >> html_string.gsub!( /src=(["'])\S+\?\d*\1/ ) { |s| s.split('?').first + >> $1 } >> >> ## the question is why can I do string concat with + $1 in the first >> regexp and >> ## why am I unable to do it in the second regexp where doing str + $1 >> throws the error?? > The side effect of String#split is changing the value of $1. It doesn't in ruby 1.8.6: irb(main):007:0> /(.)/ =~ "abc"; puts $1; "a b".split(" "); puts $1 a a => nil It will if the split is done on a Regexp (but the OP wasn't doing that) irb(main):008:0> /(.)/ =~ "abc"; puts $1; "a b".split(/ /); puts $1 a nil => nil -- Posted via http://www.ruby-forum.com/.