str.partition(sep) â [head, sep, tail]str.partition(regexp) â [head, match, tail]
Instance Public methods
Searches sep or pattern (regexp) in 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".partition("l") #=> ["he", "l", "lo"]
"hello".partition("x") #=> ["hello", "", ""]
"hello".partition(/.l/) #=> ["h", "el", "lo"]