Q:

How to remove all `/` characters present at the end of a string?

I am using Ruby on Rails 3.2.9 and Ruby 1.9.3. Given a string I would like to remove all / characters present at the end of that string. That is, for instance:
From "abc/"   to "abc"
From "abc//"  to "abc"
From "abc///" to "abc"
...
From "a/b/c///" to "a/b/c"

How can I make that (maybe by using a regex)?

I tried:
string = string[0,string.length-1] if string.end_with?('/')

but it works just for one character.

A:

"abc//".sub %r{/+$}, ''

this will only delete / at the end of the string.
I use %r{} to make a regexp because I don't have to escape the / in this case.

