Answers for "ruby replace a number in a string with a new number"

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

Code answers related to "ruby replace a number in a string with a new number"

Browse Popular Code Answers by Language