Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUBY

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')
 
PREVIOUS NEXT
Tagged: #ruby #replace #character #string
ADD COMMENT
Topic
Name
8+6 =