rpartition

str.rpartition(sep) â [head, sep, tail]
str.rpartition(regexp) â [head, match, tail]
Instance Public methods

Searches sep or pattern (regexp) in the string from the end of the string, and returns the part before it, the match, and the part after it. If it is not found, returns two empty strings and str.

"hello".rpartition("l")         #=> ["hel", "l", "o"]
"hello".rpartition("x")         #=> ["", "", "hello"]
"hello".rpartition(/.l/)        #=> ["he", "ll", "o"]
doc_ruby_on_rails
2015-05-15 18:36:03
Comments
Leave a Comment

Please login to continue.