From: sto.mar@... Date: 2012-09-07T22:34:53+09:00 Subject: Re: cant change the string Am 07.09.2012 12:32, schrieb Ferdous ara: > > but I want > > if host_name =~ /^BD/ > host_name.gsub("BD","DK") > puts host_name > end > > so if hostname is BD, it will change it to DK (this number can be > change anytime) > So End result will be > > DK55 > > but its not working > > Can any one please help me Tip: form a habit of using irb to find out what is "not working": 1.9.3p194 :001 > host_name = 'BD55' => "BD55" 1.9.3p194 :002 > host_name.gsub("BD","DK") => "DK55" 1.9.3p194 :003 > puts host_name BD55 => nil ... and you can see that host_name.gsub(...) returns the expected modified string, but host_name is unchanged. --