Answers for "ruby replace first character in string"

0

ruby replace first character in string

To replace the first two characters of a string with 'Hello':

x = "This is a test"
puts x.sub(/^../, 'Hello')
Posted by: Guest on January-27-2022

Code answers related to "ruby replace first character in string"

Browse Popular Code Answers by Language