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
Generally, Ruby methods tend to return a new object rather than mutating
an existing one. Mutating methods often have a bang postfix, i.e. "gsub!".
This is not enforced by Ruby language itself, but is a useful convention.
So, you need to use `host_name.gsub!("BD", "DK")'.
Generally, Ruby methods tend to return a new object rather than
mutating
an existing one. Mutating methods often have a bang postfix, i.e.
"gsub!".
This is not enforced by Ruby language itself, but is a useful
convention.
So, you need to use `host_name.gsub!("BD", "DK")'.