method
rpartition
v1_8_7_72 -
Show latest stable
- Class:
String
rpartition(p1)public
Searches sep in the string from the end of the string, and returns the part before it, the sep, and the part after it. If sep is not found, returns two empty strings and str.
"hello".rpartition("l") #=> ["hel", "l", "o"] "hello".rpartition("x") #=> ["", "", "hello"]
1Note
Right Partitioning Filename extension
1.9.3p392 :013 > x = "picture.2.jpg" => "picture.2.jpg"
1.9.3p392 :015 > x.rpartition('.') => ["picture.2", ".", "jpg"]