method

rpartition

v1_9_3_125 - Show latest stable - Class: String
rpartition(p1)
public

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"]

1Note

Right Partitioning Filename extension

marceloaustria ยท Mar 19, 20141 thank

1.9.3p392 :013 > x = "picture.2.jpg" => "picture.2.jpg"

1.9.3p392 :015 > x.rpartition('.') => ["picture.2", ".", "jpg"]