From: Sebastian Hungerecker Date: 2007-09-22T19:19:03+09:00 Subject: Re: regex problem with gsub Gilbert Rebhan wrote: > str=File.basename(Dir["J:/test/*.xml"].sort[0]).gsub(/(\w{8}).+/, $1) At this point $1 is nil, which is why you get the error. You have to keep in mind that arguments are evaluated before the method is called and $1 will only have value after that. You need to use '\1' instead of $1. HTH, Sebastian -- Jabber: sepp2k@jabber.org ICQ: 205544826