From: Craig Jolicoeur Date: 2009-04-29T22:16:06+09:00 Subject: Re: Issue with regexp pattern matcher withing String#gsub Heesob Park wrote: > 2009/4/29 Craig Jolicoeur : >> ## 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. > > You can work acound like this: > html_string.gsub!( /src=(["'])\S+\?\d*\1/ ) {|s| t=$1;s.split('?').first > + t } > > Regards, > > Park Heesob ahh, interesting. thanks so much. I didn't realize that #split would overwrite those methods. What exactly does the split function set them to? -- Posted via http://www.ruby-forum.com/.