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"]
Register or
log in
to add new notes.
marceloaustria -
March 19, 2014 - (v1_8_6_287 - v1_9_3_392)
1 thank
Right Partitioning Filename extension
1.9.3p392 :013 > x = “picture.2.jpg”
=> "picture.2.jpg"
1.9.3p392 :015 > x.rpartition(‘.’)
=> ["picture.2", ".", "jpg"]