Answers for "change string ruby"

1

ruby replace certain character

# Ruby language
str_old = "first-name last-name"
str_old.sub("-", "_") 		# Replace first "-" with "_"
str_old.gsub("-", "_") 		# Replace all "-" with "_"
Posted by: Guest on May-21-2020
0

replace strring by another string ruby

myString = "Welcome to JavaScript!"

myString["JavaScript"]= "Ruby"

puts myString
=> "Welcome to Ruby!"
Posted by: Guest on June-04-2020

Browse Popular Code Answers by Language