Reputation: 75945
I'm trying to basically trying to remove the .
in the the string .extension
So I'm using
'.extension'[1..10] #gives extension
Of course this will work for 10 characters, how would I make it work for any length. I dont know what to search for because I dont know what this array style [x..y]
is called.
Upvotes: 3
Views: 11039
Reputation: 230316
You can use negative indexes. This will offset them from the end. -1 is the last element, -2 is the second last and so on.
'.extension'[1..-1] # => extension
Upvotes: 18