Slice a string : slice « String « Ruby






Slice a string


string = 'My first string'                   # => "My first string"


string.slice(3, 5)                        # => "first"

 








Related examples in the same category

1.String slice and index
2.Negative index in slice